Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $application = Application::create(['name' => 'Soda']);
     $application_url = ApplicationUrl::create(['application_id' => $application->id, 'domain' => 'soda.dev', 'folder' => '']);
     $user = User::create(['name' => 'admin', 'email' => '*****@*****.**', 'password' => \Hash::make('password')]);
     $role_global_admin = Role::create(['name' => 'global_admin', 'display_name' => 'Global Administrator', 'description' => 'User is the administrator of all applications', 'application_id' => $application->id]);
     $role_admin = Role::create(['name' => 'admin', 'display_name' => 'Administrator', 'description' => 'User is the administrator of a given application', 'application_id' => $application->id]);
     $role_user = Role::create(['name' => 'user', 'display_name' => 'User', 'description' => 'Standard user (authenticated)', 'application_id' => $application->id]);
     $role_guest = Role::create(['name' => 'guest', 'display_name' => 'Guest', 'description' => 'Unauthenticated user', 'application_id' => $application->id]);
     $basic_admin = Permission::create(['name' => 'basic-admin', 'display_name' => 'Basic Admin', 'description' => 'User can access basic admin features', 'section' => 'admin', 'application_id' => $application->id]);
     $manage_own_permissions = Permission::create(['name' => 'manage-own-permissions', 'display_name' => 'Manage own permissions', 'description' => 'User can manage own permissions', 'section' => 'admin', 'application_id' => $application->id]);
     $manage_permissions = Permission::create(['name' => 'manage-permissions', 'display_name' => 'Manage permissions', 'description' => 'User can manage permissions', 'section' => 'admin', 'application_id' => $application->id]);
     $manage_groups = Permission::create(['name' => 'manage-roles', 'display_name' => 'Manage roles', 'description' => 'User can manage roles', 'section' => 'admin', 'application_id' => $application->id]);
     $manage_users = Permission::create(['name' => 'manage-users', 'display_name' => 'Manage users', 'description' => 'User can manage users', 'section' => 'admin', 'application_id' => $application->id]);
     $user->applications()->attach($application);
     $role_global_admin->attachPermission($basic_admin);
     $role_global_admin->attachPermission($manage_own_permissions);
     $role_global_admin->attachPermission($manage_permissions);
     $role_global_admin->attachPermission($manage_groups);
     $role_global_admin->attachPermission($manage_users);
     $role_admin->attachPermission($basic_admin);
     $role_admin->attachPermission($manage_own_permissions);
     $role_admin->attachPermission($manage_permissions);
     $role_admin->attachPermission($manage_groups);
     $role_admin->attachPermission($manage_users);
     $user->attachRole($role_global_admin);
 }
Beispiel #2
0
 /**
  * Auto generated seed file
  *
  * @return void
  */
 public function run()
 {
     $developer = User::create(['username' => 'Developer', 'email' => '*****@*****.**', 'password' => Hash::make('katana12')]);
     $admin = User::create(['username' => 'Admin', 'email' => '*****@*****.**', 'password' => Hash::make('admin')]);
     $admin_role = Role::whereName('admin')->first();
     $developer_role = Role::whereName('developer')->first();
     if ($admin_role) {
         $admin->attachRole($admin_role);
     }
     if ($developer_role) {
         $developer->attachRole($developer_role);
         $developer->attachRole($admin_role);
     }
 }
Beispiel #3
0
 protected function loadEvents()
 {
     $this->app->events->listen('Illuminate\\Routing\\Events\\RouteMatched', function () {
         $user = $this->app->auth->user();
         if ($user) {
             $this->user = User::find($user->id);
         }
         $this->user = User::loadGuest();
     });
     $this->app->events->listen('auth.login', function ($user) {
         $user->loggedin_at = Carbon::now();
         $user->save();
     });
 }
Beispiel #4
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  *
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }