/** * Handle the event. * * @param LeadSubmitted $event * @return Boolean */ public function handle(LeadSubmitted $event) { // Query for attribution entry if available $attribution = Attribution::where('landing_page_id', $event->lead->landing_page_id)->where('email', $event->lead->email)->where('lead_id', 0)->orderBy('created_at', 'DESC')->first(); // If attribution entry is found already, set the lead id if (!is_null($attribution)) { $attribution->lead_id = $event->lead->id; $event->lead->has_attribution = true; $attribution->save(); $event->lead->save(); } return true; }
/** * Remove the specified resource from storage. * * @param AdminDestroyRequest $request * @param Integer $id * @return Response */ public function destroy(AdminDestroyRequest $request, $id) { $lead = Lead::findOrFail($id); if (strtolower($request->get('fullname')) == strtolower($lead->fullname)) { $lead->delete(); Attribution::where('lead_id', $id)->delete(); return redirect('leads')->with('status', \Lang::get('lead.destroy.successful', ['fullname' => $lead->fullname])); } else { return redirect('leads/' . $lead->id . '/delete')->with('status', \Lang::get('lead.destroy.unsuccessful', ['fullname' => $lead->fullname])); } }