Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #eager #loading #clause
ADD COMMENT
Topic
Name
1+6 =