Tipps und Ranglisten erste Basic Version
This commit is contained in:
parent
7a33f5f889
commit
12651fc2e8
6 changed files with 99 additions and 9 deletions
|
|
@ -15,12 +15,8 @@ use DB;
|
|||
|
||||
class TippsController extends Controller
|
||||
{
|
||||
public function createTipps() {
|
||||
public static function createTipps($user_id) {
|
||||
$activeSeason = Season::getCurrent();
|
||||
$user=Auth::user();
|
||||
|
||||
// Log::info($user->id);
|
||||
// Log::info("** Start: createTipps for " . $activeSeason->name . "**");
|
||||
|
||||
$rounds = Round::all()->where('season_id', '=', $activeSeason->id);
|
||||
foreach($rounds as $round) {
|
||||
|
|
@ -31,12 +27,12 @@ class TippsController extends Controller
|
|||
// Tipp erzeugen wenn noch nicht vorhanden
|
||||
$tipp = DB::table('tipps')->where([
|
||||
['game_id','=',$game->id],
|
||||
['user_id','=',$user->id]]
|
||||
['user_id','=',$user_id]]
|
||||
)->first();
|
||||
if (! $tipp) {
|
||||
//Log::info('Creating missing tip: game_id=' . $game->id . ", user_id=" . $user->id);
|
||||
$tipp=Tipp::create([
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user_id,
|
||||
'game_id'=> $game->id,
|
||||
'score1'=> -1,
|
||||
'score2'=> -1,
|
||||
|
|
@ -50,6 +46,13 @@ class TippsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public static function createAllTips(){
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
foreach($users as $user) {
|
||||
TippsController::createTipps($user->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$activeSeason = Season::getCurrent();
|
||||
|
|
@ -58,7 +61,7 @@ class TippsController extends Controller
|
|||
$user = Auth::user();
|
||||
|
||||
|
||||
$this->createTipps(); // ggfs. fehlender Tipp Eintraege einfügen
|
||||
TippsController::createTipps($user->id); // ggfs. fehlender Tipp Eintraege einfügen
|
||||
|
||||
|
||||
if ($activeSeason) {
|
||||
|
|
|
|||
|
|
@ -84,4 +84,10 @@ class UsersController extends Controller
|
|||
return redirect('/users');
|
||||
}
|
||||
|
||||
public function ranking() {
|
||||
TippsController::createAllTips();
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
return view('users.ranking', compact('users'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue