我在数据库中有一个表用户
id,name,users_type
有多种类型的users_type,如Admin,Sub Admin,Unsigned,Normal User
我想获得所有类型的users_type但不是管理员用户。
如果您正在使用雄辩的模型
$users = User::where('users_type', '!=', 'Admin')->get();
使用查询生成器
$users = DB::table('users')->where('users_type', '!=', 'Admin')->get();
检查这个查询生成器https://laravel.com/docs/5.6/queries和Eloquent你可以看看这个https://laravel.com/docs/5.6/eloquent
$users = User::where('users_type','<>','Admin')->get();
你想得到等于的结果,然后不需要添加=
如果你只想获得一个用户,那么使用qazxsw poi而不是qazxsw poi