/** * Audit the Auditable model. * * @param \OwenIt\Auditing\Contracts\Auditable $model * * @return \Illuminate\Database\Eloquent\Model */ public function audit(Auditable $model) { $report = Audit::create($model->toAudit()); if ($report) { $model->clearOlderAudits(); } return $report; }
/** * {@inheritdoc} */ public function audit(Auditable $model) { $auditors = $model->getAuditors(); foreach ((array) $auditors as $auditor) { $model = clone $model; // Review audit if (!$this->auditReview($model, $auditor)) { continue; } $report = $this->driver($auditor)->audit($model); // Report audit $this->app->make('events')->fire(new Events\AuditReport($model, $auditor, $report)); } }
/** * Handle the deleted event for the model. * * @param \OwenIt\Auditing\Contracts\Auditable $model * * @return void */ public function deleted(Auditable $model) { $model->prepareAudit(); $model->auditDeletion(); }