/** * Run the migrations. * * @return void */ public function up() { $actions = Action::where('action', 'signed up')->get(); foreach ($actions as $action) { Signup::firstOrCreate(['campaign_id' => $action->campaign_id, 'contact_id' => $action->contact_id]); } }
/** * Display the specified resource. * * @param $guildSlug * @param $occurrenceId * @return \Illuminate\Http\Response */ public function show($guildSlug, $occurrenceId) { $guild = Guild::where('slug', $guildSlug)->firstOrFail(); $occurrence = EventOccurrence::with(['event', 'event.guild'])->whereHas('event.guild', function ($query) use($guild) { $query->where('id', $guild->id); })->findOrFail($occurrenceId); $event = $occurrence->event; $guild = $event->guild; $signups = Signup::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get(); $comments = Comment::where(['event_occurrence_id' => $occurrence->id])->orderBy('created_at')->get(); $character = Character::whereHas('guilds', function ($query) use($guild) { $query->where('guilds.id', $guild->id); })->where(['user_id' => Auth::user()->id])->firstOrFail(); $ownSignup = null; $isSigned = false; foreach ($signups as $signup) { if ($signup->character_id == $character->id) { $ownSignup = $signup; $isSigned = true; } } if ($ownSignup == null) { $ownSignup = new Signup(); } $statistic = new \stdClass(); foreach (['YES', 'MAYBE', 'NO'] as $status) { $name = strtolower($status); $statistic->{$name} = $signups->filter(function ($signup) use($status) { return $signup->status == $status; })->count(); } return view('guilds.events.show', compact('occurrence', 'event', 'guild', 'signups', 'comments', 'ownSignup', 'isSigned', 'statistic')); }
/** * 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]); }
public function epVikingsSubmit(Request $request) { if ($request->input('salted_id')) { $originalEmail = Email::where('salted_id', '=', $request->input('salted_id'))->first(); } if ($originalEmail) { if ($request->input('self') === 'yes') { Signup::firstOrCreate(['contact_id' => $originalEmail->contact->id, 'campaign_id' => $originalEmail->campaign->id]); } else { Signup::where('contact_id', $originalEmail->contact->id)->where('campaign_id', $originalEmail->campaign->id)->delete(); } if ($request->input('guest') === 'yes') { Signup::create(['contact_id' => $originalEmail->contact->id, 'campaign_id' => $originalEmail->campaign->id]); } } if ($request->input('self') === 'no') { return redirect()->back()->with('message', "Sorry you can't make it."); } return redirect()->back()->with('message', "Thanks for the RSVP, looking forward to seeing you."); }
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; }