Yajra No available engine for AppUser
I’ve made for my cms admins role
now i have 2 admin roles super admin and normal admin
i have a page that manage users both super admin and normal admin can see it but with different data
here’s the controller code
public function index()
{
$this->super_admin_role_check();
return view('admin.users.index');
}
public function usersList(){
$super_admin_role = Role::where('name','super_admin')->first();
$is_super_admin=$this->isSuperAdmin();
if($is_super_admin){
$data = User::all();
}else{
// Admin can get all users except super admin
$super_admin = DB::table('role_user')->where('role_id',$super_admin_role->id)->first();
$data = User::where('id','!=',$super_admin->user_id)->first();
}
if(!$data){
$data=[];
}
return DataTables::of($data)->make(true);
}
// This function check if the super_admin roles exist or not
public function super_admin_role_check(){
$user = Auth::guard()->user();
$super_admin_role = Role::where('name','super_admin')->first();
if(!$super_admin_role){
Artisan::call('db:seed');
// if there's no role factory create super_admin role and assign it to the super admin user
$super_admin_role = Role::where('name','super_admin')->first();
DB::table('role_user')->insert([
'user_id'=>$user->id,'role_id'=>$super_admin_role->id
]);
$permissions = Permission::all();
// here i give all permissions to the super admin
foreach($permissions as $permission){
DB::table('permission_role')->insert(['permission_id'=>$permission->id,
'role_id'=>$super_admin_role->id
]);
}
}
return $super_admin_role;
}
// This Function Check if the user is super admin?
public function isSuperAdmin(){
$user = Auth::guard()->user();
$super_admin_role = Role::where('name','super_admin')->first();
$is_super_admin = DB::table('role_user')->where('user_id',$user->id)->where('role_id',$super_admin_role->id)->first();
return $is_super_admin;
}
The problem is that when i’m login as super admin everythings goes well but when i’m login as normal admin i get error “No available engine for AppUser”
in vendoryajralaravel-datatables-oraclesrcDataTables.php
any help please?
from Laravel Questions and Answers https://laravelquestions.com/laravel/yajra-no-available-engine-for-appuser/
via Lzo Media
No comments:
Post a Comment