/** * Display a listing of reports * * @return Response */ public function index() { if (!Report::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $users_under_me = Auth::user()->getAuthorizedUserids(Report::$show_authorize_flag); if (empty($users_under_me)) { $reports = Report::whereNotNull('reports.created_at'); } else { $reports = Report::whereIn('reports.user_id', $users_under_me); } $reports = $reports->select(['reports.id', 'reports.name', 'reports.model', 'reports.path', 'reports.is_json', 'reports.id as actions']); return Datatables::of($reports)->edit_column('actions', function ($report) { $actions = []; $actions[] = $report->canShow() ? link_to_action('ReportsController@show', 'Show', $report->id, ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $report->canUpdate() ? link_to_action('ReportsController@edit', 'Update', $report->id, ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $report->canDelete() ? Former::open(action('ReportsController@destroy', $report->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-xs btn-danger confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); return Datatables::of($reports)->make(); } Asset::push('js', 'datatables'); return View::make('reports.index'); }
$gt++; break; } if (count($players[0]->opponents($tournament)->where('players.id', '=', $players[$pt])->get()) == 0) { $games[$gt]->players = array($players[0], $players[$pt]); $gt++; unset($players[$pt]); unset($players[0]); $players = array_values($players); $pt = 0; continue; } } return $games; } } Round::deleting(function ($round) { $games = $round->games()->get(); $gamesToDelete = array(); foreach ($games as $game) { $gamesToDelete[] = $game->id; } Report::whereIn('game', $gamesToDelete)->delete(); Game::whereIn('id', $gamesToDelete)->delete(); $tournament = $round->tournament(); $players = $tournament->players()->get(); foreach ($players as $player) { $player->updateScore($tournament); $player->updateSos($tournament); } });
/** * @return \Illuminate\View\View * @throws Exception * */ public function rawWeatherTable() { $title = 'Raw weather'; $fields = Config::get('marauder.rawWeatherEntries'); // all of the users log entries: $get = ['reports.id', 'reports.time']; /* * get the users cities: */ $structures = Auth::user()->structures()->get(); $cities = []; /** @var Structure $structure */ foreach ($structures as $structure) { $city = City::findCity($structure->postal_code, $structure->country_code); $cities[] = $city->id; } $cities = array_unique($cities); $query = Report::whereIn('reports.city_id', $cities)->take(Config::get('marauder.weatherTableLimit'))->orderBy('time', 'DESC')->orderBy('reports.city_id', 'ASC'); foreach ($fields as $field) { $query->withReportValue($field); $fieldName = str_replace('.', '_', $field); $get[] = $fieldName . '.value as ' . $fieldName; } $result = $query->get($get); if ($result->count() > 0) { $result = $result->toArray(); } foreach ($result as $key => $entry) { foreach ($entry as $name => $value) { $result[$key][$name] = Format::format($name, $value); } } $ignore = []; return View::make('raw.table', compact('result', 'title', 'ignore')); }