dimanche 31 janvier 2021

Laravel execute where condition based on variable null or not

I am new to laravel. I want to execute my where condition if my variable value is not null. I tried the below code exactly not getting an idea of what to do.

$search = $array['search'];
$id = $array['id'];
$Data = Model::where('id', '=', $id)

if($search != '') {
    //I want to include where condition here
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3pDvHzE
via IFTTT

Aucun commentaire:

Enregistrer un commentaire