Answer the question
In order to leave comments, you need to log in
How to work with Repository in Laravel?
I do not quite understand how to work with repositories in Laravel, for example, if I have a request like:
DB::table('trips')
->join('routes', 'routes.trip_id', '=', 'trips.id')
->join('vehicles', 'trips.vehicle_id', '=', 'vehicles.id')
->where('trips.user_id', '=', $id)
->get(['trips.id','from', 'to', 'brand', 'model', 'start_at', 'end_at']);
Trip:all();
Answer the question
In order to leave comments, you need to log in
If there are connections, then use them.Trip::with('routes')->with('vehicles')->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question