/** * Here we want to display relevant data for the selected campaign. We will have to relate several * tables here in order to show interactions and link back to the profile poage * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $campaign = \App\Campaigns::findOrFail($id); $template = \App\Templates::where('id', 1)->orderBy('name', 'desc')->take(10)->get(); $emailSent = \App\EmailSent::where('campaigns_id', $id)->get(); /* Create array of fields for our WHERE statement */ $tableOptions = ['campaigns_id' => $id, 'event' => 'opened']; $tableOptions2 = ['campaigns_id' => $id, 'event' => 'clicked']; $tableOptions3 = ['campaigns_id' => $id, 'event' => 'failed']; $emailOpens = \App\EmailInteractions::where($tableOptions)->get(); $emailClicks = \App\EmailInteractions::where($tableOptions2)->get(); $emailFailed = \App\EmailInteractions::where($tableOptions3)->get(); return view('campaigns.show', compact('campaign'))->with('emailSent', $emailSent)->with('emailOpens', $emailOpens)->with('emailClicks', $emailClicks)->with('emailFailed', $emailFailed); }