owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.05k stars 390 forks source link

Adding auditable to model breaks it in Laravel 10 #820

Closed EM-LilianaIturribarria closed 1 year ago

EM-LilianaIturribarria commented 1 year ago
Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 10.0
Package version 13.5
PHP version 8.1

Actual Behaviour

I have this model:

`<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\SoftDeletes; use OwenIt\Auditing\Auditable as AuditableConcrete; use OwenIt\Auditing\Contracts\Auditable;

final class AdType extends Model implements Auditable { use AuditableConcrete; use SoftDeletes;

/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
protected $fillable = [
    'name',
    'width',
    'height',
    'in_gam',
];

public function websites(): BelongsToMany
{
    return $this->belongsToMany(Website::class);
}

public function channels(): HasManyThrough
{
    return $this->hasManyThrough(Channel::class, Website::class);
}

} `

and when i try to use it, it gives me the following error:

Declaration of OwenIt\Auditing\Auditor::execute(OwenIt\Auditing\Contracts\Auditable $model) must be compatible with OwenIt\Auditing\Contracts\Auditor::execute(OwenIt\Auditing\Contracts\Auditable $model): void

Expected Behaviour

it should work? i followed the documentation from the site and added these to my models.

Steps to Reproduce

It just affects all models when i add the Auditable

Possible Solutions

No idea

parallels999 commented 1 year ago

I'm using Laravel 10.x, Php 8.1, and auditing 13.5.0, everything is working as expected, Also Laravel 10.x, Php 8.1 is tested https://github.com/owen-it/laravel-auditing/actions/runs/4493293879/jobs/7904320396 try composer update -W or share a repo with a minimal application showing the problem

EM-LilianaIturribarria commented 1 year ago

i found the issue, on the documentation this step is not there: php artisan auditing:install

with that everything worked.

parallels999 commented 1 year ago

https://laravel-auditing.com/guide/installation.html