Пример #1
0
 public function index()
 {
     $winners = $this->winner->getWinnersOfPreviousPeriods();
     $currentPeriod = $this->period->checkPeriod();
     $periods = $this->period->all();
     return view('index', compact('winners', 'currentPeriod', 'periods'));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Get the time of now
     $time = Carbon::now()->toDateTimeString();
     $periods = Period::all();
     // Check if time is between start and end of a period
     foreach ($periods as $period) {
         if ($time >= $period->start && $time <= $period->end) {
             if (!$period->running) {
                 $period->running = 1;
                 $period->save();
             }
         } elseif ($period->running) {
             // Last period ends here + a mail of all the winners of that period is send to the admin
             $period->running = 0;
             $period->save();
             $winners = Winner::where('period', $period->id)->get();
             $data = ['title' => 'Winners of period ' . $period->id, 'content' => '', 'winners' => $winners];
             Mail::send('emails.winners', $data, function ($message) {
                 $message->to('*****@*****.**', 'Oscar');
                 $message->subject('Winners');
             });
         }
     }
 }
Пример #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $periods = \App\Period::all();
     return view('Admin.Period.period', compact('periods', $periods));
     //return view('Admin.Period.Project.project');
 }
Пример #4
0
 public function checkPeriod()
 {
     $currentDate = Carbon::now();
     $periods = Period::all();
     foreach ($periods as $period) {
         if ($currentDate > $period->start_date && $currentDate < $period->end_date) {
             return $period;
         }
     }
 }
Пример #5
0
 public function periods()
 {
     if (Auth::check()) {
         $periods = Period::all();
         $currentPeriod = $this->period->checkPeriod();
         $codes = Keycode::all();
         return view('admin/periods', compact('currentPeriod', 'periods', 'codes'));
     } else {
         return view('errors/404');
     }
 }
 public function getAll()
 {
     $period = new Period();
     $current_period = $period->active()->first();
     $img = new Image();
     $periods = $period->all();
     $winners = [];
     $pp_images = !is_null($current_period) ? $img->pastperiod($current_period)->get() : null;
     $rules = ['Hi everyone! Welcome to the Zeal Optics Ski Goggles Game!', 'The game goes on for 4 periods.', 'The photo with the most votes wins!', 'Every period a new winner is selected!', 'The rules are simple: register, post the most amazing and unique photo from your last ski vacation.', 'Sit back, relax and wait until the end of the period!', 'After every period the winners will be published on this page.', 'You can only post once!', 'You can als vote, but also only once for each photo!'];
     $past_periods = $period->past()->get();
     if ($past_periods) {
         foreach ($past_periods as $key => $p) {
             $winners['Period ' . ($key + 1)] = Votes::winners($p);
         }
     }
     $images = $current_period != null ? $img->with('author')->active($current_period)->get() : null;
     return view('home', compact('images', 'winners', 'rules', 'pp_images', 'periods'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $periods = Period::all();
     $admin_email = $this->getEmail();
     return view('admin.index', compact('admin_email', 'periods'))->withTitle('Admin');
 }
 public function getWinners()
 {
     $user = Auth::user();
     $username = $user->name;
     $userPoints = $user->points;
     $title = 'Dashboard winners';
     // get all periods to see how many exist
     $periods = Period::all();
     // get all winners of every period
     foreach ($periods as $period) {
         $winners[] = Winner::where('period', $period->id)->get();
     }
     return view('dashboard.winner.all', compact('title', 'username', 'userPoints', 'winners', 'periods'));
 }
Пример #9
0
 public function getWinners()
 {
     if (Auth::user()->admin) {
         $title = 'admin winners';
         $periods = Period::all();
         // get all the winners for every period
         foreach ($periods as $period) {
             $winners[] = Winner::where('period', $period->id)->get();
         }
         return view('admin.winners', compact('title', 'periods', 'winners'));
     } else {
         return redirect('dashboard');
     }
 }