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>
108 lines
2.5 KiB
PHP
108 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
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 = [
|
|
'name',
|
|
'slug',
|
|
'contact_name',
|
|
'contact_email',
|
|
'phone',
|
|
'website',
|
|
'billing_status',
|
|
'settings',
|
|
'email_logo_url',
|
|
'email_primary_color',
|
|
'email_reply_to',
|
|
'email_sender_name',
|
|
'email_footer_text',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'settings' => 'array',
|
|
];
|
|
}
|
|
|
|
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')
|
|
->withPivot('role')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function events(): HasMany
|
|
{
|
|
return $this->hasMany(Event::class);
|
|
}
|
|
|
|
public function invitations(): HasMany
|
|
{
|
|
return $this->hasMany(UserInvitation::class);
|
|
}
|
|
|
|
public function crowdTypes(): HasMany
|
|
{
|
|
return $this->hasMany(CrowdType::class);
|
|
}
|
|
|
|
public function companies(): HasMany
|
|
{
|
|
return $this->hasMany(Company::class);
|
|
}
|
|
|
|
public function personTags(): HasMany
|
|
{
|
|
return $this->hasMany(PersonTag::class);
|
|
}
|
|
|
|
public function registrationFieldTemplates(): HasMany
|
|
{
|
|
return $this->hasMany(RegistrationFieldTemplate::class);
|
|
}
|
|
|
|
public function emailSettings(): HasOne
|
|
{
|
|
return $this->hasOne(OrganisationEmailSettings::class);
|
|
}
|
|
|
|
public function emailTemplates(): HasMany
|
|
{
|
|
return $this->hasMany(OrganisationEmailTemplate::class);
|
|
}
|
|
|
|
public function emailLogs(): HasMany
|
|
{
|
|
return $this->hasMany(EmailLog::class);
|
|
}
|
|
}
|