/** * Store a new cost log associated with material from form request * * @param Request $request * @param Material $material * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store_cost_log(Request $request, Material $material) { $this->authorize('edit_material'); $this->validate($request, ['mat_cost_cost_kg' => 'required|numeric|min:0', 'mat_cost_date' => 'required|date']); $material->costLogs()->save(MaterialCostLog::create($request->all())); flash()->success('Material Cost Saved', 'A new cost log has been added to the material'); // return redirect()->action('MaterialController@index'); }