public function checkIfCodeIsValid($code) { $currentPeriod = $this->period->checkPeriod(); $result = Keycode::where('code', '=', $code)->where('used', '=', '0')->where('period_id', '=', $currentPeriod->id)->first(); if ($result) { return $result; } else { return false; } }
public function checkWinner($code) { $currentUser = Auth::user(); $currentCode = Keycode::where('code', '=', $code)->first(); $winner = Winner::where('user_id', '=', $currentUser->id)->first(); if (!$winner) { Winner::create(['user_id' => $currentUser->id, 'keycode_id' => $currentCode->id]); return true; } else { return false; } }