Пример #1
0
 public function update(PlayFormRequest $request, $id)
 {
     $play = Play::findOrFail($id);
     if (Gate::denies('access-play', $play)) {
         abort(404);
     }
     $gcf = Gcf::findOrFail($play->gcf_id);
     if ($this->workingAreaId !== 'WK1047') {
         $play->basin_name = DB::table('basin_working_area')->where('working_area_id', '=', $this->workingAreaId)->value('basin_name');
     }
     DB::transaction(function () use($play, $gcf, $request) {
         $play->update($request['play']);
         $gcf->update($request['gcf']);
     });
     session()->flash('success', 'Play successfully updated, thank you!');
     return redirect('play');
 }
Пример #2
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');
 }