/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $author = new User();
     $authors = $author->all();
     $match = new Match();
     $matches = $match->all();
     return view('commentary.index')->with('authors', $authors)->with('matches', $matches);
 }
 /**
  * Delete all matches action(reboot ladder).
  *
  * @param  Request  $request
  * @return Response
  */
 public function deleteMatches(Request $request)
 {
     if (!$request->user()->admin) {
         abort(403);
     }
     foreach (Match::all() as $match) {
         $match->delete();
     }
     return view('match.partials.table')->with('matches', Match::all());
 }
 /**
  * Remove old posts.
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function clean()
 {
     $trainings = Training::all();
     $matches = Match::all();
     foreach ($matches as $match) {
         if ($match->kickoff < Carbon::now()->subHours(6)) {
             $match->delete();
         }
     }
     foreach ($trainings as $training) {
         if ($training->date_time < Carbon::now()->subHours(3)) {
             $training->delete();
         }
     }
     return redirect('/');
 }
Example #4
0
 /**
  * Matches List view
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function matches()
 {
     $matches = Match::all();
     //dd ($matches);
     return view('teams.matches', ['matches' => $matches]);
 }
Example #5
0
<?php

use App\Player;
use App\Match;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('start');
});
Route::get('ny-match', 'MatchController@create');
Route::post('ny-match', 'MatchController@store');
Route::get('player/{index}/addpoint', function ($index) {
    $match = Match::all()->last();
    $player = $match->players[$index - 1];
    Event::fire(new App\Events\PlayerScoredPoint($player, true));
});
Route::get('match/startnewset', function () {
    $match = Match::all()->last();
    Event::fire(new App\Events\StartNewSet($match));
});
Route::get('match/{id}', 'MatchController@show');