コード例 #1
0
ファイル: AuthController.php プロジェクト: PovilasLT/maze
 public function postRegister(CreateUser $request)
 {
     $user = User::create(['username' => $request->input('username'), 'email' => $request->input('email'), 'password' => Hash::make($request->input('password'))]);
     $user->attachRole(Role::where('name', '=', 'Narys')->get()->first());
     event(new UserWasCreated($user));
     flash()->success('Tu sėkmingai užsiregistravai! Dabar gali prisijungti!');
     return redirect('/');
 }
コード例 #2
0
 public function setupFoundorAndBaseRolsPermission()
 {
     //use this to set up admin accounts
     // Create Roles
     $founder = new Role();
     $founder->name = 'Įkūrėjas';
     $founder->save();
     $admin = new Role();
     $admin->name = 'Administratorius';
     $admin->save();
     $mod = new Role();
     $mod->name = 'Moderatorius';
     $mod->save();
     $premium = new Role();
     $premium->name = 'Premium Narys';
     $premium->save();
     $member = new Role();
     $member->name = 'Narys';
     $member->save();
     // Create Permissions
     $manageTopics = new Permission();
     $manageTopics->name = 'manage_topics';
     $manageTopics->display_name = 'Manage Topics';
     $manageTopics->save();
     $manageStatuses = new Permission();
     $manageStatuses->name = 'manage_statuses';
     $manageStatuses->display_name = 'Manage Status Updates';
     $manageStatuses->save();
     $manageComments = new Permission();
     $manageComments->name = 'manage_comments';
     $manageComments->display_name = 'Manage Comments';
     $manageComments->save();
     $manageUsers = new Permission();
     $manageUsers->name = 'manage_users';
     $manageUsers->display_name = 'Manage Users';
     $manageUsers->save();
     $manageUsers = new Permission();
     $manageUsers->name = 'manage_replies';
     $manageUsers->display_name = 'Manage Posts';
     $manageUsers->save();
     // Assign Permission to Role
     $founder->perms()->sync([$manageTopics->id, $manageUsers->id, $manageStatuses->id, $manageComments->id]);
     $admin->perms()->sync([$manageTopics->id, $manageUsers->id, $manageStatuses->id]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $mod = Role::where('name', 'Moderatorius')->first();
     $mod->perms()->sync([1, 2, 3, 5]);
 }