i have created AdminMiddleware and i have written code as mention below but Auth::user will not work because i want to use Admin table instead of user table.
public function handle($request, Closure $next)
{
$Admin = \App\Admin::all()->count();
if (!($Admin == 1)) {
if (!Auth::user()->hasPermissionTo('Administer roles & permissions')) //If user does //not have this permission
{
abort('401');
}
}
return $next($request);
}
You need to change App\\User
model class to App\\Admin
model class (you need to create it).
Edit file config/auth.php
key prowiders.users.model
set to App\\Admin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.