laravel when clause code example
Example: laravel when condition
$invisiblePosts = $request->query('invisible');
Article::query()
->when($invisiblePosts , function ($query){
return $query->where('invisible' , true);
},function ($query){
return $query->where('invisible' , false);
})
->get();