/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param $guildSlug
  * @param $occurrenceId
  * @param $signupId
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $guildSlug, $occurrenceId, $signupId)
 {
     $signup = Signup::with(['occurrence', 'occurrence.event', 'occurrence.event.guild', 'character', 'character.user'])->whereHas('occurrence', function ($query) use($occurrenceId) {
         $query->where('id', $occurrenceId);
     })->whereHas('occurrence.event.guild', function ($query) use($guildSlug) {
         $query->where('slug', $guildSlug);
     })->findOrFail($signupId);
     if ($signup->character->user->id != Auth::user()->id) {
         abort(401, 'Not owner of that signup');
     }
     $signup->update($request->only('status'));
     $signup->save();
     return redirect()->route('guilds.events.show', [$guildSlug, $occurrenceId]);
 }
Ejemplo n.º 2
0
 public function campaignSignups($id)
 {
     $campaign = Campaign::find($id);
     $signups = Signup::with('contact')->where('campaign_id', '=', $campaign->id)->orderBy('contact_id', 'DESC')->get(['contact_id']);
     $signups = array_map(function ($signup) {
         foreach ($signup['contact'] as $key => $value) {
             $signup[$key] = $value;
         }
         unset($signup['contact_id'], $signup['id'], $signup['contact'], $signup['unsubscribe'], $signup['client_id'], $signup['updated_at'], $signup['created_at']);
         return $signup;
     }, $signups->toArray());
     $metrics = Excel::create("{$campaign->name} Signups", function ($excel) use($campaign, $signups) {
         $today = Carbon::now()->format('M jS');
         $excel->setTitle("Event Signups as of {$today} for {$campaign->name}");
         $excel->setCreator("EP-Productions");
         $excel->setCompany('Exhibit Partners');
         $excel->setDescription("Event Signups from an email campaign for {$campaign->client}->name");
         $excel->sheet('Signups', function ($sheet) use($signups) {
             $sheet->fromArray($signups);
         });
     })->download('xlsx');
     return $metrics;
 }