public function patchEditAgent(Request $request) { $name = $request->input('name'); $value = $request->input('value'); $agent = Agents::where('id', $request->input('pk'))->first(); $agent->{$name} = $value; $agent->save(); return $value; }
public function sendToZipCode($inputs) { //Create a new text record $messageId = Appointment_Message::create(['lead_id' => $inputs['lead_id'], 'responses' => 0, 'zipcode' => $inputs['zipcode']]); $zipcode = Zipcode::find($inputs['zipcode']); $agents = AgentData::where('zip', $inputs['zipcode'])->groupBy('agent_id')->get([DB::raw("agent_id,zip,agent_id, COUNT(CASE WHEN source IN ('S','B') THEN 1 END) as closings,COUNT(CASE WHEN source IN ('O') THEN 1 END) as office,COUNT(CASE WHEN source IN ('H') THEN 1 END) as home,COUNT(CASE WHEN source IN ('A') THEN 1 END) as other")])->toArray(); $array_pop = $this->filterAgentsForCollection($agents, $zipcode); $agent_collection = Agents::where('mobile_phone', '!=', '')->where('is_active', 1)->where('days_red', '<=', $zipcode->min_red)->orderBy('agent_order', 'ASC')->find($array_pop); $agent_collection->add(['messageId' => $messageId->id]); return $agent_collection; }
$mobile = $agent->phone_one; } if ($agent->phone_two_name == 'Cell') { $mobile = $agent->phone_two; } $existing_agent = \App\Agents::find($agent->agent_id); if (!$existing_agent) { $last_agent = \App\Agents::orderBy('agent_order')->get()->last(); if (!$last_agent) { $order = 1; } else { $order = $last_agent->agent_order + 1; } //dd($last_agent); \App\AgentData::create(['zip' => $agent->zip, 'source' => 'O', 'agent_id' => $agent->agent_id]); \App\Agents::create(['id' => $agent->agent_id, 'first_name' => $agent->first_name, 'last_name' => $agent->last_name, 'agent_full_name' => $agent->last_name . ', ' . $agent->first_name, 'email_address' => $agent->email, 'mobile_phone' => $mobile, 'office_phone' => $agent->phone_one, 'office' => $agent->address1, 'photo' => $agent->photo, 'agent_order' => $order]); } } return redirect('admin'); }); // Helper routes /** *Image manipulation */ Route::get('img/{path}', function (League\Glide\Server $server, \Illuminate\Http\Request $request) { $server->outputImage($request); })->where('path', '.*'); /** * */ Route::get('roles', function () {
/** * @param Request $request * @return mixed */ public function incomingAppointmentRequest(Request $request) { $inboundRequest = $request->all(); $body = $inboundRequest['Body']; $from_phone = $inboundRequest['From']; $appointmentMessage = Appointment_Message::find($body); if (!$appointmentMessage) { return response()->view('admin.messaging.responses.wrong_code')->header('Content-Type', 'text/xml'); } $agent = Agents::where('mobile_phone', $from_phone)->with('messages')->first(); $agent->messages()->attach($appointmentMessage->id); $zipcode = $appointmentMessage->zipcode; // No message exists, tell the user the wrong code was entered //Other wise, give the user feedback, fire an event and return xml to the user if ($appointmentMessage->responses == 0) { $appointmentMessage->responses = 1; $appointmentMessage->agent_id = $agent->id; $appointmentMessage->save(); //event(new AppointmentWasAssigned($agent)); return response()->view('admin.messaging.responses.lead_accepted', compact('zipcode', 'from_phone'))->header('Content-Type', 'text/xml'); } // Always assume failure and return the response return response()->view('admin.messaging.responses.lead_was_taken')->header('Content-Type', 'text/xml'); }