/** * Execute the console command. * * @return void */ public function fire() { $input = ['name' => trim($this->argument('name')), 'email' => trim($this->argument('email')), 'password' => $this->option('password')]; if (is_null($input['name'])) { $this->error('You must set a username as the first argument.'); return; } if (is_null($input['email'])) { $this->error('You must set an email address as the first argument.'); return; } $val = Validator::make($input, ['name' => ['required', 'unique:' . Auth::getTableName('users') . ',name'], 'email' => ['required', 'email', 'unique:' . Auth::getTableName('users') . ',email']]); if ($val->fails()) { $errors = array_values($val->errors()->all()); $this->error(implode("\n", $errors)); return; } Auth::createUser($input, $this->option('activate'), !$this->option('suppress')); $this->comment('Created a user.'); $this->output->writeln(' Username: <info>' . $input['name'] . '</info>'); $this->output->writeln(' Email Address: <info>' . $input['email'] . '</info>'); $this->output->writeln(' Password: <info>' . $input['password'] . '</info>'); $this->output->writeln(' Activated: <info>' . ($this->option('activate') ? 'Yes' : 'No') . '</info>'); $this->output->writeln(''); return; }
/** * Run the database seeds. * * @return void */ public function run() { $table = Auth::getTableName('permissions'); DB::table($table)->truncate(); $timestamp = date('Y-m-d H:i:s'); $permissions = [['permission' => 'admin', 'name' => 'Administration', 'description' => 'Full administration permissions', 'display_order' => 1, 'created_at' => $timestamp, 'updated_at' => $timestamp]]; foreach ($permissions as $permission) { DB::table($table)->insert($permission); } }
/** * Run the database seeds. * * @return void */ public function run() { $tableRoles = Auth::getTableName('roles'); $tableRolePermissions = Auth::getTableName('role_permissions'); DB::table($tableRoles)->truncate(); DB::table($tableRolePermissions)->truncate(); $timestamp = date('Y-m-d H:i:s'); $roles = [['role' => 'admin', 'name' => 'Administrator', 'access_level' => 1000, 'display_order' => 1, 'created_at' => $timestamp, 'updated_at' => $timestamp, 'permissions' => [1]], ['role' => 'mod', 'name' => 'Moderator', 'access_level' => 500, 'display_order' => 2, 'created_at' => $timestamp, 'updated_at' => $timestamp], ['role' => 'member', 'name' => 'Member', 'access_level' => 100, 'display_order' => 3, 'default' => true, 'created_at' => $timestamp, 'updated_at' => $timestamp]]; foreach ($roles as $role) { $permissions = isset($role['permissions']) ? $role['permissions'] : []; if (isset($role['permissions'])) { unset($role['permissions']); } $roleId = DB::table($tableRoles)->insertGetId($role); foreach ($permissions as $permissionId) { $rolePermission = ['role_id' => $roleId, 'permission_id' => $permissionId, 'created_at' => $timestamp, 'updated_at' => $timestamp]; DB::table($tableRolePermissions)->insert($rolePermission); } } }
/** * Run the database seeds. * * @return void */ public function run() { $tableUsers = Auth::getTableName('users'); $tableUserRoles = Auth::getTableName('user_roles'); DB::table($tableUsers)->truncate(); DB::table($tableUserRoles)->truncate(); $defaultPassword = Hash::make('password'); $timestamp = date('Y-m-d H:i:s'); $users = [['name' => 'Admin', 'password' => $defaultPassword, 'email' => '*****@*****.**', 'first_name' => 'Admin', 'last_name' => 'Istrator', 'created_at' => $timestamp, 'updated_at' => $timestamp, 'activated_at' => $timestamp, 'roles' => [1]], ['name' => 'TestUser', 'password' => $defaultPassword, 'email' => '*****@*****.**', 'first_name' => 'Test', 'last_name' => 'Userone', 'created_at' => $timestamp, 'updated_at' => $timestamp, 'activated_at' => $timestamp, 'test' => true, 'roles' => [2]], ['name' => 'TestUser2', 'password' => $defaultPassword, 'email' => '*****@*****.**', 'first_name' => 'Test', 'last_name' => 'Usertwo', 'created_at' => $timestamp, 'updated_at' => $timestamp, 'activated_at' => $timestamp, 'test' => true, 'roles' => [3]], ['name' => 'TestUser3', 'password' => $defaultPassword, 'email' => '*****@*****.**', 'first_name' => 'Test', 'last_name' => 'Userthree', 'created_at' => $timestamp, 'updated_at' => $timestamp, 'activated_at' => $timestamp, 'test' => true, 'roles' => [3]]]; foreach ($users as $user) { $roles = isset($user['roles']) ? $user['roles'] : []; if (isset($user['roles'])) { unset($user['roles']); } $userId = DB::table($tableUsers)->insertGetId($user); foreach ($roles as $roleId) { $userRole = ['user_id' => $userId, 'role_id' => $roleId, 'created_at' => $timestamp, 'updated_at' => $timestamp]; DB::table($tableUserRoles)->insert($userRole); } } }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::drop(Auth::getTableName('role_permissions')); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::drop(Auth::getTableName('user_permissions_cached')); }
/** * Reverse the migrations. * * @return void */ public function down() { Schema::drop(Auth::getTableName('user_states')); }