Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Roles
     $admin = new Role();
     $admin->name = 'admin';
     $admin->display_name = 'Admin';
     $admin->description = 'Administration users';
     $admin->save();
     $user = new Role();
     $user->name = 'user';
     $user->display_name = 'User';
     $user->description = 'Registered users';
     $user->save();
     // Permissions
     $permission_user = new Permission();
     $permission_user->name = 'user-administration';
     $permission_user->display_name = 'User: Administration';
     $permission_user->description = 'CRUD users';
     $permission_user->save();
     $permission_video = new Permission();
     $permission_video->name = 'video-administration';
     $permission_video->display_name = 'Video: Administration';
     $permission_video->description = 'CRUD video';
     $permission_video->save();
     $admin->attachPermissions([$permission_user, $permission_video]);
     // User
     $admin_user = User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin']);
     $admin_user->attachRole($admin);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $user = User::create(['username' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin']);
     // add admin role
     $adminRole = Role::where('name', 'admin')->first();
     $user->attachRole($adminRole);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // add permission the admin role
     $adminRole = Role::where('name', 'admin')->first();
     // block
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Block', $type);
         $adminRole->attachPermission($permission);
     }
 }
Exemplo n.º 4
0
 /**
  * Formbuilder.
  *
  * @param null       $form
  * @param Model|null $entry
  *
  * @return array
  */
 public function getForm($form = null, Model $entry = null)
 {
     $selectedRoles = null;
     if (!is_null($entry)) {
         // only for edit
         $selectedRoles = $entry->roles->pluck('id')->toArray();
     }
     $roles = Role::pluck('display_name', 'id');
     $formFields = ['id' => $form->hidden('id'), 'user_id' => $form->hidden('user_id'), 'username' => $form->text(trans('user::user.username'), 'username'), 'email' => $form->text(trans('user::user.email'), 'email'), 'password' => $form->password(trans('user::user.password'), 'password'), 'password_confirmation' => $form->password(trans('user::user.password_confirm'), 'password_confirmation'), 'user.roles' => $form->select(trans('user::role.roles'), 'roles')->options($roles)->multiple()->select($selectedRoles), 'submit' => $form->submit(trans('crud::crud.save'))];
     return $formFields;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // add permission the admin role
     $adminRole = Role::where('name', 'admin')->first();
     // user
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('User', $type);
         $adminRole->attachPermission($permission);
     }
     // role
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Role', $type);
         $adminRole->attachPermission($permission);
     }
     // Permission
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Permission', $type);
         $adminRole->attachPermission($permission);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // add permission the admin role
     $adminRole = Role::where('name', 'admin')->first();
     // page
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Page', $type);
         $adminRole->attachPermission($permission);
     }
     // topic
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Topic', $type);
         $adminRole->attachPermission($permission);
     }
     // category
     foreach ($this->getPermissionsTypes() as $type) {
         $permission = $this->createPermission('Category', $type);
         $adminRole->attachPermission($permission);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'Registered users']);
     Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'Administration users']);
 }