/** * Run the database seeds. * * @return void */ public function run() { $roles = Config::get('seeders.roles'); foreach ($roles as $role) { $role = Role::create(['name' => $role['name'], 'display_name' => $role['display_name'], 'description' => $role['description']]); } }
/** * Get some data to dashboard. * * /amdmin/dashboard/information get * * @return \Illuminate\Http\JsonResponse */ public function dashboard() { // get user number. $this->data['user_count'] = DB::table('users')->count(); // get all roles. $this->data['all_roles'] = Role::with(['users', 'perms'])->get(); // get all permissions ... now not work for me. // $this->data['all_perms'] = Permission::all(); // get video count. $this->data['video_count'] = DB::table('videos')->count(); // get blog count. $this->data['blog_count'] = DB::table('blogs')->count(); // get subscriber count. $this->data['subscriber_count'] = DB::table('subscribers')->count(); return $this->responseJson(['info' => $this->data]); }
/** * Create a new user. * * @return \Learner\Models\User */ protected function createAUser() { $args = func_get_args(); $newUser = User::create(['username' => $args[0], 'nickname' => $args[1], 'email' => $args[2], 'avatar' => $args[3]]); $userRole = Role::whereName('user')->first(); $newUser->roles()->attach($userRole); return $newUser; }