Skip to content

Instantly share code, notes, and snippets.

@novaknole
Created September 4, 2019 17:22
Show Gist options
  • Save novaknole/e3a80c3dc4fc9ef318d666311abc73be to your computer and use it in GitHub Desktop.
Save novaknole/e3a80c3dc4fc9ef318d666311abc73be to your computer and use it in GitHub Desktop.
$vehicle = App\Http\Models\Vehicle::findOrFail(2);
return $vehicle->with([
'latestPrice' => function($query) {
$query->where('milleage', 1000)->latest('id');
},
'latestDamage' => function($query){
$query->where('user_id', 1)->latest();
},
'latestDamage.images'
])->first();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment