. */ declare(strict_types=1); namespace FireflyIII\Repositories\AuditLogEntry; use FireflyIII\Models\AuditLogEntry; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; /** * Class ALERepository */ class ALERepository implements ALERepositoryInterface { /** * @inheritDoc */ public function store(array $data): AuditLogEntry { $auditLogEntry = new AuditLogEntry; $auditLogEntry->auditable()->associate($data['auditable']); $auditLogEntry->changer()->associate($data['changer']); $auditLogEntry->action = $data['action']; $auditLogEntry->before = $data['before']; $auditLogEntry->after = $data['after']; $auditLogEntry->save(); return $auditLogEntry; } /** * @inheritDoc */ public function getForObject(Model $model): Collection { return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', get_class($model))->get(); } }