Reputation: 558
If I try to put on another model only new created record is auditing. Update, delete is not working.
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;
class Brands extends Model implements Auditable
{
use \OwenIt\Auditing\Auditable;
use Notifiable;
use HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'brand_name', 'brand_status'
];
protected $auditInclude = [
'brand_name', 'brand_status'
];
}
I don't know why in User model it is tracking all events. But in another model, only the newly created record is tracking and not other things like deleting, updating it is not tracking.
Upvotes: 1
Views: 3570
Reputation: 3971
Inside your config/audit.php
, make sure that the timestamps
setting is set to true
. This allows the created_at
, updated_at
and deleted_at
timestamps to be audited.
'timestamps' => true,
EDIT: Add created_at
, updated_at
and deleted_at
inside your protected $auditInclude
fuunction
protected $auditInclude = [
'brand_name', 'brand_status', 'created_at', 'updated_at', 'deleted_at'
];
Upvotes: 1