/**
  * Display the specified resource.
  *
  * @param  ShowRequest $request
  * @param  Integer  $id
  * @return Response
  */
 public function show(ShowRequest $request, ChartContract $chart, $id)
 {
     $campaign = Campaign::where('id', $id)->with(['landing_pages' => function ($q) {
         $q->orderBy('created_at', 'DESC');
     }])->with(['comments' => function ($q) {
         $q->orderBy('created_at', 'DESC');
     }])->first();
     // Instantiate campaign leads collection
     $campaign->leads_data = collect();
     // Set chart date
     $chart->init($this->start_date, $this->end_date);
     // Add an iterator loop for different chart colors
     foreach ($campaign->landing_pages as $i => $landing_page) {
         // Get total lead count for date range
         $landing_page->leads_sum = $landing_page->leads()->where('created_at', '>', $this->start_date)->count();
         // Get landing page leads, grouped by day
         $landing_page->leads_data = $landing_page->getLeads($this->length);
         // Set dataset
         $chart->setLineBarDataSet($landing_page->leads_data, $landing_page->title, $i);
         // Push landing page dataset into campaign dataset
         $campaign->leads_data->push($chart->getDataSet());
         $landing_page->leads_graph = $chart->getLineBarChart();
     }
     $campaign->leads_graph = $chart->getLineBarChart($campaign->leads_data);
     // Get attribution data
     $campaign->attribution_data = \App\Attribution::getLeadCountSplit($campaign->landing_pages->lists('id'));
     $campaign->attribution = $chart->getPieChart($campaign->attribution_data);
     return view('campaigns.single')->with('has_admin_access', $campaign->isAdmin())->with('user', $this->user)->with('campaign', $campaign);
 }
 /**
  * Display the specified resource.
  *
  * @param  ShowRequest $request
  * @param  ChartContract $chart
  * @param  Integer $id
  * @return Response
  */
 public function show(ShowRequest $request, ChartContract $chart, $id)
 {
     $landing_page = Landing_Page::find($id);
     // Get leads, grouped by day
     $landing_page->leads_data = $landing_page->getLeads($this->length);
     // Get total lead count for date range
     $landing_page->leads_sum = $landing_page->leads()->where('created_at', '>', $this->start_date)->count();
     $chart->init($this->start_date, $this->end_date);
     $chart->setLineBarDataSet($landing_page->leads_data, $landing_page->title);
     $landing_page->leads_graph = $chart->getLineBarChart();
     // Get attribution data
     $landing_page->attribution_data = Attribution::getLeadCountSplit([$landing_page->id]);
     $landing_page->attribution = $chart->getPieChart($landing_page->attribution_data);
     return view('landing_pages.single')->with('has_admin_access', $landing_page->isAdmin())->with('user', $this->user)->with('landing_page', $landing_page);
 }