Answers for "add where condition in relationship laravel"

PHP
2

laravel where condition on relationship

AppRequest::where('id',4)
    ->whereHas('quotes', function ($query) {
        $query->where('status','=','3');
    })
    ->with('quotes','sourceTable','destinationTable')
    ->get();
Posted by: Guest on November-30-2020
0

Laravel - Add conditional where clause in query

$user_to_mail = User::where('store_id', $item->store_id)
                    ->when($store->notification_role_id > 0, function ($q) use ($store) {
                        return $q->where('role_id', $store->notification_role_id);
                    })
                    ->get();
Posted by: Guest on November-15-2021

Code answers related to "add where condition in relationship laravel"

Browse Popular Code Answers by Language