示例#1
0
 public function showProfile($user)
 {
     $u = User::where('pseudo', '=', $user)->first();
     if (is_null($u)) {
         App::abort(404);
     }
     if (Auth::user() == $u) {
         $editable = true;
     } else {
         $editable = false;
     }
     $expData = ExperienceManager::getExpInfo($u);
     return view('user.showProfile', ['user' => $u, 'streamer' => $u->isStreamer(), 'editable' => $editable, 'level' => $expData['level'], 'progression' => $expData['progression']]);
 }
示例#2
0
 /**
  * @param ExperienceManager $experienceManager
  * @return JsonResponse
  */
 public function updateWatching(ExperienceManager $experienceManager)
 {
     $validator = Validator::make(Request::all(), ['token' => 'required', 'streamer' => 'required']);
     if ($validator->fails()) {
         return new JsonResponse($validator->errors(), 422);
     }
     if ($this->streamingUser->has(Request::input('streamer'))) {
         $data = $experienceManager->processExpRequest(Request::all());
         switch ($data) {
             case ExperienceManager::NEED_RESYNC:
                 $status = 400;
                 break;
             default:
                 $status = 200;
                 break;
         }
         // TODO : check data returned to see if it's ok or need resync
     } else {
         // Error : no streaming in progress
         $status = 400;
     }
     return new JsonResponse($data, $status);
 }
示例#3
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('user')->truncate();
     DB::table('role')->truncate();
     DB::table('role_user')->truncate();
     DB::table('event')->truncate();
     DB::table('exp_level')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $faker = Factory::create();
     $uQ = new User();
     $uQ->login = '******';
     $uQ->pseudo = 'QsAnakrose';
     $uQ->password = Hash::make('quentin');
     $uQ->email = '*****@*****.**';
     $uQ->streaming = 1;
     $uQ->twitch_channel = 'riotgames';
     $uQ->save();
     $data = [];
     for ($i = 0; $i < 110; $i++) {
         $username = $faker->unique()->username;
         $data[] = ['login' => $username, 'pseudo' => $username, 'email' => $faker->unique()->freeEmail, 'password' => Hash::make($username)];
     }
     User::insert($data);
     $this->command->info('Users created');
     $admin = new Role();
     $admin->title = 'admin';
     $admin->save();
     $streamer = new Role();
     $streamer->title = 'streamer';
     $streamer->save();
     $this->command->info('Roles created');
     $uQ->becomeAdmin();
     $uQ->becomeStreamer();
     for ($i = 2; $i < 13; $i++) {
         $u = User::find($i);
         $u->becomeStreamer();
         $u->twitch_channel = $i;
         $u->description = $u->login . 'lorem ipsum dolor. Lol.';
         $rand = rand(0, 2);
         if ($rand == 0) {
             $u->streaming = 1;
         } else {
             $u->streaming = 0;
         }
         /*
         $avatarManager = new AvatarManager();
         $intervManager = $avatarManager->getImgManager();
         $width = $avatarManager->getAvatarWidth();
         $color = substr(md5(rand()), 0, 6);
         $intervManager->canvas($width, $width, $color);
         */
         $u->save();
     }
     $su = new StreamingUserService();
     $su->update();
     $this->command->info('Roles attached');
     $event = new Event();
     $event->title = 'Hugo';
     $event->start = '2015-06-26T12:30:00+02:00';
     $event->end = '2015-06-26T15:30:00+02:00';
     $event->allDay = 'false';
     $event->color = '#FF0000';
     $event->timezone = '+02:00';
     $event->save();
     $this->command->info('Test event created');
     $expManager = new ExperienceManager();
     $data = $expManager->generateExperienceSystem();
     ExpLevel::insert($data);
     $this->command->info('Experience system initialized');
 }