false, 'status' => true, ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'firstname', 'lastname', 'email', 'uuid', 'profile', 'status', 'is_admin', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'is_admin' => 'boolean', 'status' => 'boolean', 'password' => 'hashed', ]; public function logAction(): HasMany { return $this->hasMany(Log::class); } public function logs(): MorphOne { return $this->morphOne(Log::class, 'loggable'); } public function getFullNameAttribute(): string { return "$this->firstname $this->lastname"; } public static function boot(): void { parent::boot(); self::created(function ($model) { Log::create([ 'user_id' => auth()?->user()?->id ?? 1, 'loggable_type' => self::class, 'loggable_id' => $model->id, 'action' => LogAction::CREATE, 'content' => $model->full_name, 'ip' => request()->ip(), ]); }); } }