Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('permissions')->truncate();
     DB::table('permission_role')->truncate();
     // Create superadmin permissions
     $permissions = $this->getSuperadminPermissionsList();
     $role = Role::whereName('SUPERADMIN')->first();
     foreach ($permissions as $permission) {
         Permission::create(['name' => $permission]);
         $role->givePermissionTo($permission);
     }
     // Create admin permissions
     $permissions = $this->getAdminPermissionsList();
     $role = Role::whereName('ADMINISTRATOR')->first();
     foreach ($permissions as $permission) {
         Permission::create(['name' => $permission]);
         $role->givePermissionTo($permission);
     }
     // Associate editor permissions
     $permissions = $this->getEditorPermissionsList();
     $role = Role::whereName('EDITOR')->first();
     foreach ($permissions as $permission) {
         Permission::create(['name' => $permission]);
         $role->givePermissionTo($permission);
     }
 }
Ejemplo n.º 2
0
 /**
  * Creates a form for adding permissions
  *
  * @param int $id
  * @param Model $model
  * @param string $resourceMultiple
  * @return \Kris\LaravelFormBuilder\Form
  */
 protected function getAddPermissionForm($id, Model $model, $resourceMultiple)
 {
     $form = $this->form('Reactor\\Html\\Forms\\Permissions\\AddPermissionForm', ['url' => route('reactor.' . $resourceMultiple . '.permissions.add', $id)]);
     $choices = Permission::all()->diff($model->permissions)->pluck('name', 'id')->toArray();
     $form->modify('permission', 'select', ['choices' => $choices]);
     return [$form, count($choices)];
 }
Ejemplo n.º 3
0
 /**
  * @param Request $request
  * @param Permission $permission
  */
 protected function validateEditForm(Request $request, Permission $permission)
 {
     $this->validateForm('Reactor\\Html\\Forms\\Permissions\\CreateEditForm', $request, ['name' => ['required', 'max:255', 'unique:permissions,name,' . $permission->getKey(), 'regex:/^(ACCESS|EDIT|SITE|REACTOR)(_([A-Z]+))+$/']]);
 }
Ejemplo n.º 4
0
 /**
  * Helper for retrieving permissions
  *
  * @return Collection
  */
 protected function getPermissions()
 {
     return Permission::with('roles')->get();
 }