feat(organisation): enable activity logging on Organisation model
Add spatie/laravel-activitylog LogsActivity trait tracking per-field dirty changes on name, slug, contact_name, contact_email, phone, and website. Log name "organisation", skip empty logs. Used by the dashboard recent-activity feed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,11 +11,14 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
||||
use Spatie\Activitylog\Support\LogOptions;
|
||||
|
||||
final class Organisation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUlids;
|
||||
use LogsActivity;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -41,6 +44,15 @@ final class Organisation extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logOnly(['name', 'slug', 'contact_name', 'contact_email', 'phone', 'website'])
|
||||
->logOnlyDirty()
|
||||
->dontLogEmptyChanges()
|
||||
->useLogName('organisation');
|
||||
}
|
||||
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'organisation_user')
|
||||
|
||||
Reference in New Issue
Block a user