public function handle(CrudAdded $crud)
    {
        if (config('admin.add_crud_permission') && file_exists(base_path('routes/web.php'))) {
            // Create permission
            //
            // Permission::generateFor(snake_case($crud->dataType->slug));
            $role = Role::where('name', 'admin')->firstOrFail();

            // Get permission for added table
            $permissions = Permission::where(['slug' => $crud->dataType->slug])->get()->pluck('id')->all();

            // Assign permission to admin
            $role->permissions()->attach($permissions);
        }
    }
public function handle(CrudAdded $crud)
    {
        if (config('admin.add_crud_permission') && file_exists(base_path('routes/web.php'))) {
            // Create permission
            //
            // Permission::generateFor(snake_case($crud->dataType->slug));
            $role = Role::where('name', 'admin')->firstOrFail();

            // Get permission for added table
            $permissions = Permission::where(['slug' => $crud->dataType->slug])->get()->pluck('id')->all();

            // Assign permission to admin
            $role->permissions()->attach($permissions);
        }
    }
public function handle ( CrudAdded $ crud ) { if ( config ( 'admin.add_crud_permission' ) && file_exists ( base_path ( 'routes/web.php' ) ) ) { // Create permission // // Permission::generateFor(snake_case($crud->dataType->slug)); $ role = Role :: where ( 'name' , 'admin' ) -> firstOrFail ( ) ; // Get permission for added table $ permissions = Permission :: where ( [ 'slug' => $ crud -> dataType -> slug ] ) -> get ( ) -> pluck ( 'id' ) -> all ( ) ; // Assign permission to admin $ role -> permissions ( ) -> attach ( $ permissions ) ; } }
Create Permission for a given CRUD.

@param CrudAdded $event

@return void
Create Permission for a given CRUD .