public function store(PlayFormRequest $request) { $play = new Play($request['play']); $play->working_area_id = $this->workingAreaId; $play->rps_year = DB::table('sys_year')->where('is_active', '=', 1)->value('rps_year'); if ($this->workingAreaId !== 'WK1047') { $play->basin_name = DB::table('basin_working_area')->where('working_area_id', '=', $this->workingAreaId)->value('basin_name'); } $gcf = new Gcf($request['gcf']); DB::transaction(function () use($play, $gcf) { $gcf->save(); $play->gcf_id = $gcf->id; $play->save(); }); session()->flash('success', 'Play successfully created, thank you!'); return redirect('play'); }
/** * 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'); }