Samuel Henry
Samuel Henry

Reputation: 153

If condition with model in laravel

Regist Controller:

$check = Regist::whereMob($mob)->get();
    if($check == emptyArray()){
        return back()->with('status', 'input error!!');
    }

Here i want to return back if $check gets no input.

It produces (E_ERROR) Call to undefined function App\Http\Controllers\emptyArray()

How to check this.

Upvotes: 0

Views: 186

Answers (1)

Siva Ganesh
Siva Ganesh

Reputation: 1445

This is one of the way to check empty

if ($check->isEmpty()) {...}

or

if (empty($check)) {...}

Upvotes: 1

Related Questions