/** * Store a newly created lead in storage * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $entity = new Entity(); $entity->email = $request->email; $entity->family_name = $request->family_name; $entity->given_name = $request->given_name; $entity->title = $request->title; $entity->street_address = $request->street_address; $entity->extended_address = $request->extended_address; $entity->region = $request->region; $entity->postal_code = $request->postal_code; $entity->country_name = $request->country_name; $entity->locality = $request->locality; $entity->kind_id = $request->kind_id; $entity->save(); $lead = new Lead(); $lead->description = $request->description; $lead->email_opt_out = $request->input('email_opt_out', 'off'); $lead->include_packing = $request->input('include_packing', 'off'); $lead->lead_sources_id = $request->lead_sources_id; $lead->lead_statuses_id = $request->lead_statuses_id; $lead->entity_id = $entity->id; $lead->save(); return redirect()->route('leads.index')->with('message', 'Lead created successfully.'); }
public function store(Request $request) { $this->validate($request, ['email' => 'required|email|unique:leads|max:255']); $lead = new Lead(); $email = $request->input('email'); $lead->email = $email; $lead->save(); return redirect()->back()->with('message', 'Merci, nous avons bien noté votre email. Soyez patient, vous en saurez plus très prochainement !'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required|max:255']); $lead = new Lead(); $lead->name = $request->name; $lead->save(); $id = $lead->id; return redirect('/leads/' . $id); }
public static function storeLead($request) { $newLead = new Lead(); $newLead->name = $request->get('name'); $newLead->patient_no = $request->get('patient_number'); $newLead->phone_no = $request->get('phone_number'); $newLead->address = $request->get('address'); $newLead->date_of_birth = date('Y-m-d', strtotime($request->get('date_of_birth'))); $newLead->city = $request->get('city'); $newLead->state = $request->get('state'); $newLead->zip = $request->get('zip_code'); $newLead->save(); return redirect()->back()->with('message', 'Lead was successfuly saved'); }
/** * Endpoint which store a new lead with its lead source and forward the call * * @param Request $request Input data * @return Response Twiml to redirect call to the forwarding number */ public function store(Request $request) { $leadSource = LeadSource::where(['number' => $request->input('To')])->first(); $lead = new Lead(); $lead->leadSource()->associate($leadSource->id); $lead->city = $this->_normalizeName($request->input('FromCity')); $lead->state = $this->_normalizeName($request->input('FromState')); $lead->caller_number = $request->input('From'); $lead->caller_name = $request->input('CallerName'); $lead->call_sid = $request->input('CallSid'); $lead->save(); $forwardMessage = new Twiml(); $forwardMessage->dial($leadSource->forwarding_number); return response($forwardMessage, 201)->header('Content-Type', 'application/xml'); }
public function testSummaries() { // Given $fakeNumberOne = '+1153614723'; $fakeNumberTwo = '+1153619723'; $leadSourceOne = new LeadSource(['number' => '+1153614723', 'description' => 'Downtown south billboard', 'forwarding_number' => '+155005501']); $leadSourceTwo = new LeadSource(['number' => '+1153619723', 'description' => 'Downtown north billboard', 'forwarding_number' => '+155005502']); $leadSourceOne->save(); $leadSourceTwo->save(); $leadOne = new Lead(['caller_number' => '+148975933', 'city' => 'Some city', 'state' => 'Some state', 'caller_name' => 'John Doe', 'call_sid' => 'sup3runiq3']); $leadTwo = new Lead(['caller_number' => '+149824734', 'city' => 'Some other city', 'state' => 'Some state', 'caller_name' => 'John Doe', 'call_sid' => 'sup3runiq3']); $leadOne->leadSource()->associate($leadSourceOne->id); $leadOne->save(); $leadTwo->leadSource()->associate($leadSourceTwo->id); $leadTwo->save(); // When $responseByCity = $this->call('GET', route('lead.summary_by_city')); $responseByLeadSource = $this->call('GET', route('lead.summary_by_lead_source')); // Then $responseContentOne = json_decode($responseByCity->getContent(), true); $responseContentTwo = json_decode($responseByLeadSource->getContent(), true); $this->assertEquals([["lead_count" => 1, "city" => "Some other city"], ["lead_count" => 1, "city" => "Some city"]], $responseContentOne); $this->assertEquals([["lead_count" => 1, "description" => "Downtown south billboard", "number" => '+1153614723'], ["lead_count" => 1, "description" => "Downtown north billboard", "number" => '+1153619723']], $responseContentTwo); }
public function leads($num, $userId) { for ($i = 0; $i < $num; $i++) { $item = new Lead(); $item->progress = $this->faker->numberBetween(5, 90); $item->active = $this->faker->numberBetween(0, 1); $item->level = $this->faker->numberBetween(0, 7); $item->activity_setting = $this->faker->numberBetween(1, 2); $item->save(); $this->tags($this->faker->numberBetween(0, 3), $item->id); $user = User::find($userId); $user->leads()->attach($item->id); $entity = $this->entities(); $item->entity_id = $entity->id; $item->save(); $account = Account::find($user->account_id); $account->entities()->attach($entity); $this->activities($this->faker->numberBetween(0, 10), $item->id, $userId); } }
public function addLeadWithSelectedEntity(Request $request) { $lead = new Lead(); $lead->name = $request->name; $lead->activity_setting = $request->setting; $lead->active = 1; $lead->progress = 0; $lead->level = 0; if ($request->next_action) { $lead->next_action = Carbon::createFromFormat('m/d/Y g:i A', $request->next_action)->toDateTimeString(); } else { $lead->next_action = null; } $lead->entity_id = $request->entity_id; $lead->save(); $user = User::find($request->userId); $user->leads()->attach($lead); $account = Account::find($user->account_id); $entity = Entity::find($request->entity_id); $account->entities()->attach($entity); $activity = new Activity(); $activity->lead_id = $lead->id; $activity->user_id = $user->id; $activity->type = 'info'; $activity->status = 'done'; $activity->name = 'Created'; $activity->visible = 1; $activity->note = $request->note; $activity->schedule_time = Carbon::now()->toDateTimeString(); $activity->save(); }
/** * Menyimpan record Lead baru ke database. * * @return View */ public function store(LeadFormRequest $request) { $input = $request->except(['lead.latitude_degree', 'lead.latitude_minute', 'lead.latitude_second', 'lead.latitude_cardinal', 'lead.longitude_degree', 'lead.longitude_minute', 'lead.longitude_second', 'lead.survey']); $lead = new Lead($input['lead']); $lead->working_area_id = $this->workingAreaId; $lead->rps_year = DB::table('sys_year')->where('is_active', '=', 1)->value('rps_year'); if ($this->workingAreaId !== 'WK1047') { $lead->basin_name = DB::table('basin_working_area')->where('working_area_id', '=', $this->workingAreaId)->value('basin_name'); } $gcf = new Gcf($input['gcf']); DB::transaction(function () use($lead, $gcf) { $gcf->save(); $lead->gcf_id = $gcf->id; $lead->save(); }); session()->flash('success', 'Lead successfully created, thank you!'); return redirect('lead'); }