Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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();
 
PREVIOUS NEXT
Tagged: #laravel #condition
ADD COMMENT
Topic
Name
2+5 =