HEX
Server: nginx/1.28.3
System: Linux lightweb-s1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User: dawonefr-98 (1071)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/dnlightw-124/dn.lightweb.kr/app/Services/DynamicModel.php
<?php

namespace App\Services;

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Orchid\Attachment\Attachable;
use Orchid\Screen\AsSource;
use Spatie\Activitylog\LogOptions;
use Spatie\EloquentSortable\SortableTrait;
use Spatie\Translatable\HasTranslations;
use Orchid\Filters\Filterable;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\EloquentSortable\Sortable;

class DynamicModel extends Model implements Sortable
{
    use HasUuids, AsSource, SoftDeletes, HasFactory, Attachable, HasTranslations, Filterable;
    use LogsActivity, SortableTrait;

    protected $guarded = [];
    public array $translatable = ['title'];

    public function uniqueIds(): array
    {
        return ['uuid'];
    }


    protected $appends = [
        'created_at_formatted',
        'updated_at_formatted',
    ];

    public function getCreatedAtFormattedAttribute()
    {
        return $this->created_at->diffForHumans();
    }

    public function getUpdatedAtFormattedAttribute()
    {
        return $this->updated_at->diffForHumans();
    }


    public function getActivitylogOptions(): LogOptions
    {
        $logOptions = new LogOptions();
        $logOptions->dontSubmitEmptyLogs();
        $logOptions->logAttributes = ['*'];
        $logOptions->logExceptAttributes = ['created_at', 'updated_at'];
        $logOptions->logOnlyDirty = true;
        return $logOptions;
    }

    /**
     * The sortable configuration.
     *
     * @var array<string, mixed>
     */
    public array $sortable = [
        'order_column_name' => 'sort_order',
        'sort_when_creating' => true,
        'sort_on_has_many' => true,
    ];
}