Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Intros not being confirmed #6

Merged
merged 1 commit into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions app/Http/Controllers/ConfirmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ class ConfirmController extends Controller
use Logger;

public function confirm($code){
try {
$mensaUser = MensaUser::where('confirmation_code', $code)->firstOrFail();
} catch(ModelNotFoundException $e){
$mensaUsers = MensaUser::where('confirmation_code', $code)->get();
if(count($mensaUsers) < 0){
return redirect(route('home'))->with('error', 'Inschrijving niet gevonden!');
}

if($mensaUser->confirmed){
return redirect(route('home'))->with('error', 'Deze inschrijving is al bevestigd!');
}

$mensaUser->confirmed = true;
$mensaUser->save();
foreach($mensaUsers as $mensaUser) {
if ($mensaUser->confirmed) {
return redirect(route('home'))->with('error', 'Deze inschrijving is al bevestigd!');
}

$mensaUser->confirmed = true;
$mensaUser->save();
}
// Log the confirmation
$this->log($mensaUser->mensa, $mensaUser->user->name.' heeft hun inschrijving bevestigd.');
if(count($mensaUsers) == 1){
$this->log($mensaUser->mensa, $mensaUser->user->name.' heeft hun inschrijving bevestigd.');
} else {
$this->log($mensaUser->mensa, $mensaUser->user->name.' heeft '.count($mensaUsers).' inschrijvingen bevestigd.');
}


Mail::to($mensaUser->user)->send(new SigninConfirmed($mensaUser));

Expand Down