Beispiel #1
0
Route::get('video', function () {
    return view('tests/video');
});
Route::get('admin/agents_go', function () {
    $file = Storage::get('Agents.xml');
    $xml = simplexml_load_string($file);
    //dd($xml->agent[4]);
    $mobile = '';
    foreach ($xml->agent as $agent) {
        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