<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Olt extends Model
{
    use HasFactory;

    protected $hidden = ['password', 'community'];

    protected $fillable = [
        'gateway_uuid', 'name', 'brand', 'model', 'protocol', 'ip_address', 'telnet_port', 'external_telnet_port', 'username', 'password', 'community', 'snmp_port', 'external_snmp_port', 'mikrotik_id', 'auto_port_forward', 'management_source_ip', 'port_forward_status', 'connected', 'gateway_status', 'gateway_snapshot', 'gateway_error', 'gateway_synced_at', 'last_connected_at', 'last_checked_at', 'status', 'remarks', 'created_by', 'updated_by',
    ];

    protected $casts = [
        'port_forward_status' => 'boolean',
        'auto_port_forward' => 'boolean',
        'connected' => 'boolean',
        'gateway_snapshot' => 'array',
        'gateway_synced_at' => 'datetime',
        'last_connected_at' => 'datetime',
        'last_checked_at' => 'datetime',
        'status' => 'boolean',
    ];

    public function mikrotik()
    {
        return $this->belongsTo(Mikrotik::class);
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
