laravel-auditing
laravel-auditing copied to clipboard
Read Audit implementation from MorphMany
To allow a different Audit implementation per model the implementation should be deducted from the MorphMany given by the Auditable::audits method.
This will allow having a main Audit implementation (which defaults to OwenIt\Auditing\Models\Audit
), but also have a different implementation once the Auditable::audits method is overwritten.
Example:
class MyAuditable extends Model implements AuditableContract
{
use Auditable;
/**
* @return MorphMany<AuditOfMyAuditableModel>
*/
public function audits(): MorphMany
{
return $this->morphMany(
AuditOfMyAuditableModel::class,
'auditable',
);
}
It is a good idea! - I do need some test coverage of the feature though.
Fix on https://github.com/owen-it/laravel-auditing/commit/a08c673e31bc4d55b6f5b5dd8cc9ab9085022d15