Answers for "when in larevel"

PHP
0

when in larevel

$role = $request->input('role');

$users = DB::table('users')
                ->when($role, function ($query, $role) {
                    return $query->where('role_id', $role);
                })
                ->get();
Posted by: Guest on September-14-2020

Browse Popular Code Answers by Language