Is it possible to return model query results via different model than the one that originally made the query?
For example, if we have two models, ModelA and ModelB, and we fetch some database results:
$modelA = new ModelA;
$results = $modelA->all();
dd($results);
Instead of a collection of ModelA objects, can it somehow return ModelB objects? The desired output, for example:
Collection {#325 ▼
#modelA_Table: Array:4 [▼
0 => ModelB { #297 ▶}
1 => ModelB { #306 ▶}
2 => ModelB { #311 ▶}
3 => ModelB { #318 ▶}
]
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1oRUdO4
via IFTTT
Aucun commentaire:
Enregistrer un commentaire