Exemplo n.º 1
0
 public function index()
 {
     //总访问量
     $visits = \Cache::get('visits', 0);
     //今日注册用户
     $todayUsers = User::today()->count('user_id');
     //总用户数
     $totalUsers = User::count('user_id');
     //管理员聊天记录
     $chatMessages = AdminMessage::with('admin')->limit(10)->oldest()->get();
     //最新留言
     $guestBook = GuestBook::with('user')->limit(10)->oldest()->get();
     //最新注册用户
     $users = User::limit(24)->oldest()->get();
     //最新评论
     $comments = Comment::limit(10)->oldest()->get();
     // 总会员数量/待审核会员/普通会员/高端会员
     $user_all_num = User::count('user_id');
     $user_shenhe_num = User::status(\App\Enum\User::STATUS_CHECK)->count('user_id');
     $user_level1_num = User::level(\App\Enum\User::LEVEL_1)->count('user_id');
     $user_level3_num = User::level(\App\Enum\User::LEVEL_3)->count('user_id');
     // 自我介绍待审核数量
     $user_info_num = UserInfo::where('introduce_status', \App\Enum\User::INTRODUCE_CHECK)->count('user_id');
     // 会员相片审核数量
     $user_gallery_num = DB::table('user_gallery')->where('status', '待审核')->where('image_url', '!=', '')->count('photo_id');
     // 文章数量
     $article_num = DB::table('articles')->count('article_id');
     $res = array('user_all_num' => $user_all_num, 'user_shenhe_num' => $user_shenhe_num, 'user_level1_num' => $user_level1_num, 'user_level3_num' => $user_level3_num, 'user_info_num' => $user_info_num, 'user_gallery_num' => $user_gallery_num, 'article_num' => $article_num);
     return $this->view('index', $res);
     // return $this->view('index')->with('visits', $visits)->with('todayUsers', $todayUsers)->with('totalUsers',
     //         $totalUsers)->with('chatMessages', $chatMessages)->with('guestBook', $guestBook)->with('users',
     //         $users)->with('comments', $comments);
 }
 public function home()
 {
     $this->view->title = $this->view->site_name;
     $this->view->asset_count = Asset::count();
     $this->view->user_count = User::count();
     $this->view->crew_count = Crew::count();
     $this->view->job_list_count = JobList::count();
     $this->view->job_count = Job::count();
     $this->view->tag_count = Tag::count();
     return $this->view;
 }
Exemplo n.º 3
0
 /**
  * @param \Laravel\Socialite\Contracts\User $login
  * @return User
  */
 private function createOrFindUser($login)
 {
     $user = User::firstOrNew(['email' => $login->getEmail()]);
     if ($user->exists) {
         return $user;
     }
     $user->name = $login->getName() ?: $login->getNickname();
     $user->nickname = $login->getNickname();
     $user->password = Hash::make($login->getId() . time());
     $user->avatar = $login->getAvatar();
     $user->admin = User::count() == 0;
     $user->save();
     return $user;
 }
 public function authenticate($identity)
 {
     return \App\Model\User::count(['conditions' => 'id = :id:', 'bind' => ['id' => (int) $identity]]) > 0;
 }
Exemplo n.º 5
0
 protected function users()
 {
     if (!Schema::hasTable('users')) {
         $this->info("Creating 'users' table.");
         Schema::create('users', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->nullable();
             $table->string('username')->unique();
             $table->string('email')->nullable();
             $table->string('password', 60);
             $table->string('password_reminder', 100)->nullable();
             $table->rememberToken();
             $table->timestamps();
         });
     }
     if (User::count() == 0) {
         $this->info("No users found; creating 'admin'.");
         $adminUser = new User();
         $adminUser->username = '******';
         $adminUser->name = 'Administrator';
         $adminUser->password = bcrypt('admin');
         $adminUser->email = config('app.site_email');
         $adminUser->save();
     }
     if (!Schema::hasTable('roles')) {
         $this->info("Creating 'roles' table.");
         Schema::create('roles', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->unique();
             $table->timestamps();
         });
     }
     if (!Role::find(Role::ADMIN)) {
         $this->info("Creating admin role.");
         Role::firstOrCreate(['id' => Role::ADMIN, 'name' => trans_choice('roles.admin', 1)]);
     }
     $managerRole = Role::find(Role::MANAGER);
     if (!$managerRole) {
         $this->info("Creating manager role.");
         Role::firstOrCreate(['id' => Role::MANAGER, 'name' => trans_choice('roles.manager', 1)]);
     }
     $clerkRole = Role::find(Role::CLERK);
     if (!$clerkRole) {
         $this->info("Creating clerk role.");
         Role::firstOrCreate(['id' => Role::CLERK, 'name' => trans_choice('roles.clerk', 1)]);
     }
     if (!Schema::hasTable('role_user')) {
         $this->info("Creating 'role_user' table.");
         Schema::create('role_user', function (Blueprint $table) {
             $table->integer('user_id')->unsigned();
             $table->foreign('user_id')->references('id')->on('users');
             $table->integer('role_id')->unsigned();
             $table->foreign('role_id')->references('id')->on('roles');
             $table->primary(['user_id', 'role_id']);
         });
     }
     // If there are no administrators, make the first user an admin.
     $adminRole = Role::find(Role::ADMIN);
     if (count(User::administrators()) === 0) {
         $adminUser = User::first();
         $this->info("Making " . $adminUser->name . " an Administrator.");
         $adminUser->roles()->save($adminRole);
     }
     if (!Schema::hasTable('unavailability_types')) {
         $this->info("Creating 'unavailability_types' table.");
         Schema::create('unavailability_types', function (Blueprint $table) {
             $table->increments('id');
             $table->string('name')->unique();
             $table->string('background_colour');
             $table->string('colour');
         });
     }
     if (!Schema::hasTable('user_unavailabilities')) {
         $this->info("Creating 'user_unavailabilities' table.");
         Schema::create('user_unavailabilities', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('user_id')->unsigned()->nullable();
             $table->foreign('user_id')->references('id')->on('users');
             $table->date('start_date')->nullable();
             $table->date('end_date')->nullable();
             $table->integer('type_id')->unsigned()->nullable();
             $table->foreign('type_id')->references('id')->on('unavailability_types');
             $table->timestamps();
         });
     }
     if (!Schema::hasTable('queued_emails')) {
         $this->info("Creating 'queued_emails' table.");
         Schema::create('queued_emails', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('recipient_id')->unsigned()->nullable();
             $table->foreign('recipient_id')->references('id')->on('users');
             $table->string('subject');
             $table->string('template');
             $table->text('data');
             $table->timestamps();
         });
     }
 }