TippsController.store: Handling Auth::user() being null value

This commit is contained in:
tschneider 2021-03-22 08:31:04 +01:00
parent f6a5934439
commit 81143a0fa6
4 changed files with 53022 additions and 6 deletions

File diff suppressed because one or more lines are too long

View file

@ -132,6 +132,17 @@ class TippsController extends Controller
$user=Auth::user();
if ( is_null($user) ) {
Log::info("TippsController.store: No authenticated user detected. Aborting storage command.");
$tippLink="/tipps#";
$r=\App\Round::getFirstTippableRound();
if($r) $tippLink=$tippLink.$r->id;
// Redirect to the Rounds Index
return redirect($tippLink);
}
Log::info("TippsController::store for user-id ".$user->id);
// Fetch, modify, save Tipp
$tipp = Tipp::where('id', request('id'))->first();
$game = Game::where('id', $tipp->game_id)->first();
@ -204,7 +215,11 @@ class TippsController extends Controller
// If one fails, previous saves are kept, but user
// is redirected to edit4 page again.
public function store4() {
Log::debug("### Store4 ###");
error_log("--- Store4 ---");
// Validate form
//dd(request());
$this->validate(request(), [
'round_id' => 'required',
'game_id_1' => 'required',
@ -222,9 +237,9 @@ class TippsController extends Controller
'score2_1' => 'required',
'score2_2' => 'required',
'score2_3' => 'required',
'score2_4' => 'required',
'round_id' => 'required'
'score2_4' => 'required'
]);
error_log("Validation passed.");
$round_id= request('round_id');
$game_id_1=request('game_id_1');
@ -280,7 +295,13 @@ class TippsController extends Controller
return redirect('/tipps/edit4/'.$round_id);
}
return redirect('/tipps/');
$tippLink="/tipps#";
$r=\App\Round::getFirstTippableRound();
if($r) $tippLink=$tippLink.$r->id;
// Redirect to the Rounds Index
return redirect($tippLink);
}
// Store tipp if valid.

View file

@ -38,7 +38,7 @@ return [
|
*/
'debug' => env('APP_DEBUG', false),
'debug' => env('APP_DEBUG', true),
/*
|--------------------------------------------------------------------------

View file

@ -86,8 +86,8 @@
<input type="checkbox" name="joker_3" id="joker_3" @if($tipp3->joker===1) checked @endif>
<span>
<input type="hidden" name="tipp_id_2" value="{{ $tipp3->id }}">
<input type="hidden" name="game_id_2" value="{{ $game3->id }}">
<input type="hidden" name="tipp_id_3" value="{{ $tipp3->id }}">
<input type="hidden" name="game_id_3" value="{{ $game3->id }}">
</span>
<!-- 4 -->