/**
  * @test
  */
 public function efficiency_issues()
 {
     $issue = EfficiencyIssue::first();
     $this->assertInstanceOf(IssueCause::class, $issue->cause);
     $this->assertInstanceOf(EfficiencyReportLog::class, $issue->efficiencyReportLogs->first());
     $this->assertInstanceOf(User::class, $issue->updatedBy);
     $this->assertInstanceOf(User::class, $issue->createdBy);
 }
 /**
  * Store a new efficiency report log entry
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(StoreEfficiencyReportFormRequest $request)
 {
     $this->authorize('edit_efficiency_report');
     $log = EfficiencyReportLog::create($request->all());
     if ($request->exists('reason')) {
         $issue = EfficiencyIssue::create($request->all());
         $issue->efficiencyReportLogs()->save($log);
     }
     flash()->success('Efficiency Report Saved', 'New efficiency report entry has been made.');
     return redirect()->action('EfficiencyReportController@index');
 }
Exemplo n.º 3
0
 /**
  * Overwrite the parent boot method
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     EfficiencyIssue::creating(function ($efficiencyIssue) {
         $efficiencyIssue->created_by = \Auth::user()->id;
         $efficiencyIssue->updated_by = \Auth::user()->id;
     });
     EfficiencyIssue::updating(function ($efficiencyIssue) {
         $efficiencyIssue->updated_by = \Auth::user()->id;
     });
 }