Answers for "laravel eager loading where clause"

PHP
2

laravel eager loading where clause

$query = ""    

if ($request->has('country'){
$query = Post::with("country")->whereHas("country",function($q) use($request){
    $q->where("name","=",$request->country);
})->get()
}else{
    $query = Post::with("country")->get();
}
Posted by: Guest on August-16-2020

Code answers related to "laravel eager loading where clause"

Browse Popular Code Answers by Language