<?php

namespace App\Models;

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

class EzyPOSLicense extends Model
{
    use HasFactory;

    protected $table = 'ezypos_licenses';

    protected $fillable = [
        'master_dealer_id', 'sub_dealer_id', 'app_id', 'license_key', 'status',
        'cloud_id', 'license_type', 'change_license_count', 'registered_date',
        'api_server_url', 'backup_uuid',

    ];

    public function masterDealer()
    {
        return $this->belongsTo(MasterDealer::class, 'master_dealer_id', 'master_dealer_id');
    }

    public function subDealer()
    {
        return $this->belongsTo(SubDealer::class, 'sub_dealer_id', 'sub_dealer_id');
    }


    public function app()
    {
        return $this->belongsTo(EzyPOS::class, 'app_id', 'app_id');
    }

    public function onlineEzyPOSBackup()
    {
        return $this->hasOne(OnlineEzyPOSBackup::class, 'license_key', 'license_key');
    }
}
