/** * Fire an event that queues a message to be sent. * * @param int $id */ public function sendMessage(Message $message) { // Get competition with activity. $competitionId = request('competition_id'); $contest = Contest::find(request('contest_id')); $contest = $this->manager->appendCampaign($contest); if ($competitionId) { $competition = Competition::find($competitionId); // Get competition with activity from flash if it is there. // Otherwise, grab it. $key = generate_model_flash_session_key($competition, ['includeActivity' => true]); if (session()->has($key)) { $competition = session($key); } else { $competition = $this->manager->getCompetitionOverview($competition, true); } } // Send test emails to authenticated user. if (request('test')) { $user = Auth::user(); $user = $this->userRepository->find($user->id); $user = $this->manager->appendReportback($user, []); $users = [$user]; } else { $users = $competition->contestants; // Only send checkin messages to users who haven't reported back. if ($message->type === 'checkin') { $users = $competition->activity['inactive']; } } $resources = ['message' => $message, 'competition' => isset($competition) ? $competition : null, 'contest' => $contest, 'users' => $users, 'test' => request('test')]; // Kick off email sending event(new QueueMessageRequest($resources)); if (!$competitionId) { return redirect()->back()->with('status', 'Fired that right the hell off!'); } return redirect()->route('competitions.message', ['competition' => $competitionId, 'contest' => request('contest_id')])->with('status', 'Fired that right the hell off!'); }
/** * Remove the specified resource from storage. * * @param \Gladiator\Models\Competition $competition * @return \Illuminate\Http\Response */ public function destroy(Competition $competition) { $competition->delete(); return redirect()->route('competitions.index')->with('status', 'Competition has been deleted!'); }