I have the following eloquent collection:
$cars = Car::with(['model'])->get();
I also have a mysql stored procedure that calculates some measure based on a date range:
$getMeasure = DB::select(
'CALL measure("'.$start_date.'", "'.$end_date.'")'
);
The two columns resulted from the procedure are car_id and measure.
Is it possible when selecting the cars to also get the measure column by joining it with the result of the procedure?
I have tried to do this with:
$cars = Car::with(['model'])
->join('call measure("'.$start_date.'", "'.$end_date.'")', 'car.id', '=', 'measure.car_id')
->get();
but this doesn't work as it's looking for a table called 'call measure'.