mercredi 1 septembre 2021

how to handle null value in Laravel Eloquent?

i am new in laravel.Actually i want to filter some data on state and typeofsupply column. like if state="south australia" and typeofsupply="Inverter & Storage" then show me these rows who exist on both value.and if i filter like state="south australia" and typeofsupply=Nul.then these rows will be display who exist state of south australia and typeofsupply should be any of list(All type of supply)

public function show(Request $request){

    $typeofsupply='';
    $state='';
    if(!$request->all()==Null) {

        if(!$request->state==Null) {
            $state=$request->state;
        }
        if(!$request->typeofsupply==Null) {
            $typeofsupply=$request->typeofsupply;
        }

        $items = Postjob::where('state',$state)
                        ->where('typeofsupply',$typeofsupply)
                        ->get();
        dd($items);


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

Aucun commentaire:

Enregistrer un commentaire