I want to filter my content elements and have the following code in my controller.
public function filter ($type, $field){
$contents = Content::with(array('user' => function($query) use ($type,$field){
if($type != "all"){
$query->where('type','=',$type);
}
if($field != 'all'){
$query->where('field','=',$field);
}
}))->active()->take(50);
return view('contents.index', compact('contents'));
}
I always get an empty result. Anyone?
Thank you! :)