mercredi 26 mai 2021

Laravel - append join query after executing a query

Is that possible in laravel to append another query to a query already exceuted?! I have a query with joins but the last join I want to excute is a on to many join so for perventing the duplicates I want to append this join to the query in array for examle.

$this->model::leftjoin('Route', 'Route.RouteID', 'Trip.RouteID') ->leftjoin('ReferenceTrip', 'ReferenceTrip.ReferenceTripID', 'Trip.ReferenceTripID') ->leftjoin('route', 'route.uuid','ReferenceTripGroup.route_id') ->leftjoin('tolls', 'tolls.route_id', 'route.uuid')->get();

the last line ->leftjoin('tolls', 'tolls.route_id', 'route.uuid'); is many so it will cause duplicates, is there any solution.

also if there is any solution I will consider to use first() insted of get()



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire