laravel relationship where condition query code example
Example 1: laravel where condition on relationship
App\Request::where('id',4)
->whereHas('quotes', function ($query) {
$query->where('status','=','3');
})
->with('quotes','sourceTable','destinationTable')
->get();
Example 2: laravel if else condition in query
$query = SocialMediaFeed::where('location_id', $location_id);
if(!$filters) {
$query = $query->where('self', '<>', true);
} else {
$query = $query->orWhere('self', true);
}