If I use models this is easily resolved, but if I don’t have the availability of using models, would it be possible to get the result equivalent to ->with()
with DB::table
?
If I use models this is easily resolved, but if I don’t have the availability of using models, would it be possible to get the result equivalent to ->with()
with DB::table
?
2
Answers
No, Here is why
Laravel models are using Eloquent, which is an ORM library.
For example, a class model could have many teachers relations, and if you want to fetch a class with all the teachers, you could do something like:
With the query builder, you would need to do something like
You can look into the documentation: https://laravel.com/docs/5.6/eloquent
Ref Thread
No this is not possible Now,
Because DB row not supported elequent relation
you should use by ORM formate.
Here is some example :-
$user = user::with(‘school’)->get();