/** * @param StoreNewSlittingLogEntryFormRequest $request * @param SlittingLogSheet $slitting_log_sheet * @return \Illuminate\Http\RedirectResponse */ public function storeEntry(StoreNewSlittingLogEntryFormRequest $request, SlittingLogSheet $slitting_log_sheet) { $this->authorize('owner', $slitting_log_sheet); $this->authorize('edit_slitting_log_sheet'); SlittingLogEntry::create(['slitting_log_sheet_id' => $slitting_log_sheet->id, 'material_id' => $request->get('material_id'), 'material_type' => get_class($slitting_log_sheet->availableMaterial()->find($request->get('material_id'))), 'waste_kg' => $request->get('waste_kg'), 'waste_code_id' => $request->get('waste_code_id'), 'produced_m' => $request->get('produced_m'), 'produced_reels' => $request->get('produced_reels'), 'note' => $request->get('note')]); flash()->success('New log entry Saved!', 'The log sheet has been updated.'); return redirect()->action('SlittingLogSheetsController@edit', [$slitting_log_sheet]); }
/** * Overwrite the parent boot method * * @return void */ public static function boot() { parent::boot(); SlittingLogEntry::creating(function ($slittingLogEntry) { $slittingLogEntry->created_by = \Auth::user()->id; $slittingLogEntry->updated_by = \Auth::user()->id; }); SlittingLogEntry::updating(function ($slittingLogEntry) { $slittingLogEntry->updated_by = \Auth::user()->id; }); }
/** * @test */ public function it_has_a_statically_callable_table_name() { $tableName = App\Models\SlittingLogEntry::table(); $this->assertEquals('slitting_log_entries', $tableName); }