lily
lily

Reputation: 199

How do you display list of admin with is_admin attribute in laravel?

How do you display all list of admin that have column with the is_admin=1? with this query? because we are not passing any data in showListAdmin.

public function Admin()
    {
        $users = User::all();
        return view('admin.admins')->with('users',$users);
    }

Upvotes: 0

Views: 563

Answers (1)

OMR
OMR

Reputation: 12188

simply use where ....

public function showListAdmin()
    {
        $users = User::where('is_admin',true)->get()->all();
        return view('admin.admins')->with('users',$users);
    }

Upvotes: 3

Related Questions