- Added comprehensive documentation for `ConnectionProviderService`, outlining architectural design, coding standards, and operational flows. - Enhanced `ConnectionProvider` and `ConnectedApp` models with Spatie activity logging configuration for detailed CRUD activity tracking. - Updated delete methods in service classes to include audit logs and cascade behavior refinement. - Revised activity log migration schema for stricter typing and method structure.
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\{Model, Relations\HasMany, SoftDeletes};
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
|
|
#[Fillable(['name', 'slug'])]
|
|
final class ConnectionProvider extends Model
|
|
{
|
|
use LogsActivity, SoftDeletes;
|
|
|
|
public function connectedApps(): HasMany
|
|
{
|
|
return $this->hasMany(ConnectedApp::class);
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logFillable() // Log all fillable attributes
|
|
->logOnlyDirty() // Log only attributes that actually changed
|
|
->dontLogIfAttributesChangedOnly(['updated_at']) // Skip if only updated_at changed
|
|
->dontLogEmptyChanges() // Prevent saving logs with no changed attributes
|
|
->setDescriptionForEvent(fn (
|
|
string $eventName
|
|
) => ":causer.name {$eventName} connection provider ':subject.name'");
|
|
}
|
|
}
|