Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Latest commit

 

History

History
38 lines (30 loc) · 992 Bytes

audit-tags.md

File metadata and controls

38 lines (30 loc) · 992 Bytes

Audit Tags

The ability to tag an Audit has been present since version 5.0.0, making it convenient for filtering.

Generating tags

The Auditable interface defines a generateTags() method for generating tags for each model.

That method should return an array of strings, which will be converted into a comma separated values string on save.

By default, the Auditable trait implementation will return an empty array, which results in NULL, once the Audit is stored.

Implementation:

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;

class Article extends Model implements Auditable
{
    use \OwenIt\Auditing\Auditable;

    /**
     * {@inheritdoc}
     */
    public function generateTags(): array
    {
        return [
            $this->editor->name,
            $this->reporter->name,
            $this->designer->name,
            $this->photographer->name,
        ];
    }

    // ...
}