public function run() { DB::table('roles')->delete(); \Caravel\Role::create(['name' => 'admin']); \Caravel\Role::create(['name' => 'manager']); \Caravel\Role::create(['name' => 'editor']); }
public function postRegister(Request $request) { $validator = $this->registrar->validator($request->all()); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $user = $this->registrar->create($request->all()); $user->confirmationString = substr(sha1(rand()), 0, 32); $user->confirmed = false; if (User::count() == 1) { $adminId = \Caravel\Role::where('name', 'admin')->first()->id; $user->roles()->attach($adminId); } else { $editorId = \Caravel\Role::where('name', 'editor')->first()->id; $user->roles()->attach($editorId); } $user->push(); $willSendMail = true; if ($_ENV['APP_ENV'] == 'local' && $_ENV['MAIL_PRETEND'] == 'true') { $willSendMail = false; } return View('auth.successful-registration')->with('hideMenu', true)->with('willSendMail', $willSendMail); }