Beispiel #1
0
 /**
  * Store a new cost log associated with ink from form request
  *
  * @param Request $request
  * @param Ink $ink
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store_cost_log(Request $request, Ink $ink)
 {
     $this->authorize('edit_ink');
     $this->validate($request, ['ink_cost_log_cost_kg' => 'required|numeric|min:0', 'ink_cost_date' => 'required|date']);
     $ink->costLogs()->save(InkCostLog::create($request->all()));
     flash()->success('Ink Cost Saved', 'A new cost log has been added to the ink');
     //
     return redirect()->action('InkController@index');
 }
Beispiel #2
0
 /**
  * Overwrite the parent boot method
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     InkCostLog::creating(function ($inkCostLog) {
         $inkCostLog->ink_cost_added_user_id_fk = \Auth::user()->id;
         $inkCostLog->ink_cost_modified_user_id_fk = \Auth::user()->id;
     });
     AdhesiveCostLog::updating(function ($inkCostLog) {
         $inkCostLog->ink_cost_modified_user_id_fk = \Auth::user()->id;
     });
 }