/**
  * Display the specified resource.
  *
  * @param  \Gladiator\Models\Competition  $competition
  * @return \Illuminate\Http\Response
  */
 public function show(Contest $contest)
 {
     $contest = $this->manager->collectContestInfo($contest->id);
     $contest = $this->manager->appendCampaign($contest);
     $welcomeEmail = Message::where('contest_id', '=', $contest->id)->where('type', '=', 'welcome')->firstOrFail();
     return view('contests.show', compact('contest', 'welcomeEmail'));
 }
 /**
  * Update a message.
  *
  * @param  \Gladiator\Models\Contest  $contest
  * @param  array $data
  * @return \Gladiator\Models\Message
  */
 public function update($contest, $data)
 {
     $message = Message::where('contest_id', '=', $contest->id)->where('type', '=', $data['type'])->where('key', '=', $data['key'])->first();
     if (!$message) {
         return $this->create($contest, $data);
     }
     $attributes = $message->getFillable();
     foreach ($attributes as $attribute) {
         if (isset($data[$attribute])) {
             $message->{$attribute} = $data[$attribute];
         }
     }
     return $message->save();
 }
 /**
  * Show and send messages in a competition.
  *
  * @param  \Gladiator\Models\Competition  $competition
  * @param  \Gladiator\Models\Contest  $contest
  * @return \Illuminate\Http\Response
  */
 public function message(Competition $competition)
 {
     $key = generate_model_flash_session_key($competition, ['includeActivity' => true]);
     if (session()->has($key)) {
         $competition = session($key);
         session()->reflash();
     } else {
         $competition = $this->manager->getCompetitionOverview($competition, true);
         session()->flash($key, $competition);
     }
     $messages = Message::where('contest_id', '=', $competition->contest->id)->where('type', '!=', 'welcome')->get();
     $featuredReportbacks = FeaturedReportback::where('competition_id', '=', $competition->id)->get()->keyBy('message_id');
     return view('messages.show', compact('messages', 'competition', 'featuredReportbacks'));
 }
示例#4
0
 /**
  * Fires off an event to send an email a user.
  *
  * @param  Gladiator\Models\User     $user
  * @param  Gladiator\Models\Contest  $contest
  * @param  array $params
  * @return null|void
  */
 public function sendEmail($user, $contest, $params)
 {
     if (!isset($params)) {
         return null;
     }
     $message = Message::where($params)->first();
     if ($message) {
         $resources = ['message' => $message, 'contest' => $contest, 'users' => [$this->userRepository->find($user->id)], 'test' => false];
         event(new QueueMessageRequest($resources));
     } else {
         return null;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  string  $id  Contest ID
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $messages = Message::where('contest_id', '=', $id)->get();
     return view('messages.show', compact('messages'));
 }