- Deleted obsolete components (`Choices`, `Input`, `ListItem`, `Table`) and trait (`HasAttributeHelpers`) from the `App\View\Components` namespace. - Removed `ConnectedAppFactory` as it is no longer utilized in the current workflow.
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\{Model, Relations\BelongsTo, SoftDeletes};
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
*/
|
|
#[Fillable([
|
|
'name',
|
|
'slug',
|
|
'connection_protocol_id',
|
|
'connection_provider_id',
|
|
'connection_status_id',
|
|
])]
|
|
class ConnectedApp extends Model
|
|
{
|
|
use LogsActivity, SoftDeletes;
|
|
|
|
/**
|
|
* @return HasOne<ConnectionProtocol, $this>
|
|
*/
|
|
public function protocol(): HasOne
|
|
{
|
|
return $this->hasOne(ConnectionProtocol::class, 'id', 'connection_protocol_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<ConnectionProvider, $this>
|
|
*/
|
|
public function provider(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ConnectionProvider::class, 'connection_provider_id');
|
|
}
|
|
|
|
/**
|
|
* @return HasOne<ConnectionStatus, $this>
|
|
*/
|
|
public function status(): HasOne
|
|
{
|
|
return $this->hasOne(ConnectionStatus::class, 'id', 'connection_status_id');
|
|
}
|
|
|
|
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} connected app ':subject.name'");
|
|
}
|
|
}
|