Created
May 21, 2017 09:29
-
-
Save chriskonnertz/8e45a2bd8d923bc34fb98b685bca8b55 to your computer and use it in GitHub Desktop.
Add home team to matches page in file app/Modules/Matches/Http/Controlers/MatchesController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Modules\Matches\Http\Controllers; | |
use App\Modules\Matches\Match; | |
use URL, HTML, FrontController; | |
class MatchesController extends FrontController { | |
public function __construct() | |
{ | |
$this->modelName = 'Match'; | |
parent::__construct(); | |
} | |
public function index() | |
{ | |
$this->pageView('matches::filter'); | |
$this->indexPage([ | |
'buttons' => null, | |
'brightenFirst' => false, | |
'filter' => true, | |
'searchFor' => ['rightTeam', 'title'], | |
'tableHead' => [ | |
trans('app.date') => 'played_at', | |
trans('app.object_game') => 'game_id', | |
trans('matches::right_team') => 'right_team_id', | |
trans('matches::left_team') => 'left_team_id', | |
trans('matches::score') => 'left_score' | |
], | |
'tableRow' => function($match) | |
{ | |
if ($match->game->icon) { | |
$game = HTML::image( | |
$match->game->uploadPath().$match->game->icon, | |
$match->game->title, | |
['width' => 16, 'height' => 16] | |
); | |
} else { | |
$game = null; | |
} | |
return [ | |
$match->played_at, | |
raw($game), | |
raw(HTML::link(url('matches/'.$match->id), $match->right_team->title)), | |
raw(HTML::link(url('matches/'.$match->id), $match->left_team->title)), | |
raw($match->scoreCode()) | |
]; | |
}, | |
'actions' => null, | |
'pageTitle' => false, | |
], 'front'); | |
} | |
/** | |
* Show a match | |
* | |
* @param int $id The id of the match | |
* @return void | |
*/ | |
public function show($id) | |
{ | |
$match = Match::findOrFail($id); | |
$match->access_counter++; | |
$match->save(); | |
$this->title($match->leftTeam->title.' '.trans('matches::vs').' '.$match->rightTeam->title); | |
$this->pageView('matches::show', compact('match')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment