Ejemplo n.º 1
0
 /**
  * Store a new lead (internal)
  * 
  * @param  StoreNewLeadRequest $request
  * @return Redirect
  */
 public function postStoreLead(StoreNewLeadRequest $request)
 {
     $landing_page_id = $request->get('landing_page_id');
     $landing_page = Landing_Page::find($landing_page_id);
     // Get any custom fields
     $custom = array_where($request->all(), function ($k, $v) {
         return !in_array($k, config('lead.fields'));
     });
     $lead = Lead::create(['landing_page_id' => $landing_page_id, 'first_name' => $request->get('first_name', ''), 'last_name' => $request->get('last_name', ''), 'email' => $request->get('email', ''), 'company' => $request->get('company', ''), 'title' => $request->get('title', ''), 'phone' => $request->get('phone', ''), 'zip' => $request->get('zip', ''), 'address' => $request->get('address', ''), 'city' => $request->get('city', ''), 'state' => $request->get('state', ''), 'country' => $request->get('country', ''), 'custom' => json_encode($custom)]);
     // Send emails
     if ($landing_page->send_email) {
         foreach ($landing_page->users_to_email as $user) {
             \Mail::queue('emails.leads.create', ['lead' => $lead, 'landing_page' => $landing_page], function ($message) use($user, $landing_page) {
                 if (!$landing_page->email_title) {
                     $landing_page->email_title = \Lang::get('lead.email.new_lead', ['title' => $landing_page->title]);
                 }
                 $message->to($user->email)->subject($landing_page->email_title);
             });
         }
     }
     // Link lead to attribution entry
     \Event::fire(new LeadSubmitted($lead));
     return redirect('leads')->with('status', \Lang::get('lead.lead_created', ['landing_page' => $landing_page->title]));
 }
Ejemplo n.º 2
0
 /**
  * Display the web to lead form
  * 
  * @param  ShowRequest $request
  * @param  Integer $id
  * @return Response
  */
 public function getWebToLead(ShowRequest $request, $id)
 {
     $landing_page = Landing_Page::find($id);
     return view('landing_pages.web_to_lead')->with('user', $this->user)->with('landing_page', $landing_page);
 }