<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class GtsOrder extends Model
{
    protected $fillable = ['user_id', 'gts_service_id', 'order_number', 'provider_order_id', 'target_link', 'quantity', 'charge', 'progress', 'notes', 'status', 'provider_status', 'start_count', 'remains', 'provider_response', 'api_submitted_at', 'api_synced_at'];

    protected function casts(): array
    {
        return ['provider_response' => 'array', 'api_submitted_at' => 'datetime', 'api_synced_at' => 'datetime'];
    }

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

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function service()
    {
        return $this->belongsTo(GtsService::class, 'gts_service_id');
    }
}
