/** * 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')); }
/** * Format a table cell for table() method. * * @param array $cellData * @param string $type * @return string */ public function createElement($element, $item) { $html = ''; if (isset($element['ignore']) && $element['ignore']) { return $html; } if (isset($element['conditions']) && is_array($element['conditions'])) { $valid = $this->testAttributeConditions($item, $element['conditions']); if (!$valid) { return $html; } } $class = isset($element['class']) ? $element['class'] : ''; if (isset($element['classModifiers'])) { foreach ($element['classModifiers'] as $potentialClass => $values) { $valid = $this->testAttributeConditions($item, $values); if ($valid) { if ($class != '') { $class .= ' '; } $class .= $potentialClass; } } if ($class != '') { $element['class'] = $class; } } if (!isset($element['tag']) || $element['tag'] == "") { $element['tag'] = "a"; } if (!isset($element['attributes'])) { $element['attributes'] = []; } if (isset($element['class'])) { $element['attributes']['class'] = $element['class']; } if (isset($element['selfClosing']) && $element['selfClosing']) { $selfClosing = true; } else { $selfClosing = false; } if (isset($element['url']) && !isset($element['href'])) { $element['href'] = $element['url']; } if ($element['tag'] == "a") { $element['attributes']['href'] = ""; if (isset($element['uri'])) { $element['attributes']['href'] = url($element['uri']); } else { if (isset($element['href']) && $element['href'] != "") { $element['attributes']['href'] = $element['href']; } } } if (isset($element['attributes']) && isset($element['attributes']['href']) && class_exists('Regulus\\Identify\\Facade')) { $accessVerb = "get"; if (isset($element['attributes']['data-action-type'])) { $accessVerb = $element['attributes']['data-action-type']; } $accessible = \Regulus\Identify\Facade::hasAccess($element['attributes']['href'], $accessVerb); if (!$accessible) { return $html; } } // add data to attributes where necessary foreach ($element['attributes'] as $attribute => $value) { if (preg_match("/\\:([a-zA-Z\\_].*)/", $value, $match)) { $segments = explode('/', $match[1]); $segments[0] = isset($item[$segments[0]]) ? $item[$segments[0]] : ''; $element['attributes'][$attribute] = str_replace($match[0], implode('/', $segments), $element['attributes'][$attribute]); } } $html .= '<' . $element['tag'] . $this->attributes($element['attributes']); if (!$selfClosing) { $html .= '>'; } if (isset($element['icon']) && $element['icon'] != "") { $iconElement = config('html.icon.element'); $iconClassPrefix = config('html.icon.class_prefix'); $html .= '<' . $iconElement . ' class="' . $iconClassPrefix . trim($element['icon']) . '"></' . $iconElement . '>'; } if (isset($element['text']) && $element['text'] != "") { if (preg_match("/\\:([a-zA-Z\\_].*)/", $value, $match)) { $segments = explode('/', $match[1]); $segments[0] = isset($item[$segments[0]]) ? $item[$segments[0]] : ''; $element['text'] = str_replace($match[0], implode('/', $segments), $element['text']); } $html .= $element['text']; } if ($selfClosing) { $html .= ' />'; } else { $html .= '</' . $element['tag'] . '>'; } return $html; }