149 - Viewing Used or Invalid Invitations

This commit is contained in:
Adam Wathan
2017-12-08 12:56:19 -05:00
parent ac4d968597
commit db7ba7effd
4 changed files with 33 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ class InvitationsController extends Controller
{
$invitation = Invitation::findByCode($code);
abort_if($invitation->hasBeenUsed(), 404);
return view('invitations.show', [
'invitation' => $invitation,
]);

View File

@@ -8,6 +8,11 @@ class Invitation extends Model
{
public static function findByCode($code)
{
return self::where('code', $code)->first();
return self::where('code', $code)->firstOrFail();
}
public function hasBeenUsed()
{
return $this->user_id !== null;
}
}