public function store(Request $request) { if (Auth::check()) { $staff_id = Auth::user()->id; $sfname = Auth::user()->fname; $slname = Auth::user()->lname; } else { return redirect('auth/login'); } $datedoc = Carbon::now(-6); $contact = new Contact(); $contact->fname = $request->input('fname'); $contact->lname = $request->input('lname'); $contact->datedoc = $datedoc; $contact->sfname = $sfname; $contact->sfname = $sfname; $contact->slname = $slname; $contact->staff_id = $staff_id; // $contact->eie = 0; // $contact->dss = 0; // $contact->client_id = 0; //=== this section checks for ids ==== $inquiry_id = $request->input('inquiry_id'); $client_id = $request->input('client_id'); $episode_id = $request->input('episode_id'); $looper = 0; $vals = array($inquiry_id, $client_id, $episode_id); $flds = array('inquiry_id', 'client_id', 'episode_id'); foreach ($flds as $fld) { $contact->setAttribute($fld, Input::has($fld) ? $vals[$looper] : '0'); $looper++; } //======================= $morechks = array('eie', 'dss', 'isprimaryrefsrc', 'isroisigned', 'isrefsrc'); foreach ($morechks as $morechk) { $contact->setAttribute($morechk, Input::has($morechk) ? true : false); } $contact->contactfname = $request->input('contactfname'); $contact->contactlname = $request->input('contactlname'); $contact->phone1 = $request->input('phone1'); $contact->phone1type = $request->input('phone1type'); $contact->phone2 = $request->input('phone2'); $contact->phone2type = $request->input('phone2type'); $contact->phone3 = $request->input('phone3'); $contact->phone3type = $request->input('phone3type'); $contact->reltoclient = $request->input('reltoclient'); $contact->refsrcreltoclient = $request->input('refsrcreltoclient'); $contact->address = $request->input('address'); $contact->city = $request->input('city'); $contact->usstate = $request->input('usstate'); $contact->zip = $request->input('zip'); // $contact->isrefsrc = $request->input('isrefsrc'); // $contact->isprimaryrefsrc = $request->input('isprimaryrefsrc'); // $contact->isroisigned = $request->input('isroisigned'); $contact->save(); return redirect()->route('inquiryview', $inquiry_id); }