Exemplo n.º 1
0
 });
 // GET Form for editing a round
 Route::get('(:any)/(:num)', function ($slug, $team_id) {
     $station_id = Station::where('slug', '=', $slug)->only('id');
     $round = Round::where_team_id_and_station_id($team_id, $station_id)->first();
     return View::make('round.edit', array('round' => $round, 'station' => $round->station, 'team' => $round->team));
 });
 // GET Form for editing a round
 Route::put('(:any)/(:num)', function ($slug, $team_id) {
     $id = Round::where_station_id_and_team_id(Input::get('station_id'), Input::get('team_id'))->only('id');
     Round::update($id, Input::all());
     return Redirect::to($slug);
 });
 // GET One station
 Route::get('(:any)', function ($slug) {
     $station = Station::where('slug', '=', $slug)->first();
     if (empty($station)) {
         return Response::error('404');
     }
     $teams = Team::all();
     $stationRounds = Round::where('station_id', '=', $station->id)->get();
     $teamsAdded = array();
     $teamslist = array();
     foreach ($stationRounds as $sr) {
         $teamsAdded[] = $sr->team->id;
     }
     foreach ($teams as $team) {
         if (!in_array($team->id, $teamsAdded)) {
             $teamslist[$team->id] = $team->name;
         }
     }
 /**
  * Get stations list for rendering stations.
  *
  * @return void
  */
 public function getStationList($lineId = NULL, $stations = array())
 {
     global $data;
     global $settings;
     $stmt = Station::where('city_id', '=', $data['area']['id']);
     if ($lineId != NULL) {
         $stmt->where('station_line_id', '=', $lineId);
     }
     if (!empty($stations)) {
         $stmt->whereIn('code', $stations);
         $stmt->groupBy('code');
     }
     $stations = $stmt->get()->toArray();
     return $stations;
 }