<?php

namespace Modules\ExternalSystem\Entities;

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;

class ExternalSystem extends Model
{
    use HasUuids;

    protected $table = 'external_systems';

    protected $fillable = [
        'code',
        'name',
        'description',
        'url',
        'icon',
        'is_active',
        'starts_at',
        'ends_at',
        'opens_in_new_tab',
        'sso_enabled',
        'sso_launch_path',
        'sso_secret',
        'sso_audience',
        'sso_token_ttl',
        'require_onboarding',
        'contact_email',
        'notes',
        'sort_order',
    ];

    protected $hidden = [
        'sso_secret',
    ];

    protected function casts(): array
    {
        return [
            'is_active' => 'boolean',
            'starts_at' => 'datetime',
            'ends_at' => 'datetime',
            'opens_in_new_tab' => 'boolean',
            'sso_enabled' => 'boolean',
            'sso_secret' => 'encrypted',
            'sso_token_ttl' => 'integer',
            'require_onboarding' => 'boolean',
            'sort_order' => 'integer',
        ];
    }
}
