Beispiel #1
0
 /**
  * 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');
 }
Beispiel #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(LeadFormRequest $request, Lead $lead)
 {
     // Update an exisiting lead
     $lead->update($request->all());
     flash()->success('Lead has been updated!');
     return redirect('leads');
 }