Exemple #1
0
 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;
 }
Exemple #2
0
        if ($agent->phone_one_name == 'Cell') {
            $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', '.*');
/**
*
*/
 public function getShowAgent($id)
 {
     $agent = Agents::where('id', $id)->with('agentData')->first();
     $extra_data = AgentData::getAgentDataGrouped($id);
     return view('admin.agents.agent_view', compact('agent', 'extra_data'));
 }