<?php

namespace App\Models;

use App\Traits\TenantScoped;
use App\Models\Machine\Machine;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StaffCardLog extends Model
{
    use TenantScoped;

    public $timestamps = false;

    protected $fillable = [
        'company_id',
        'staff_card_id',
        'machine_id',
        'payment_type',
        'code_id',
        'order_id',
        'action',
        'remark',
        'raw_data',
    ];

    protected $casts = [
        'raw_data' => 'array',
        'created_at' => 'datetime',
    ];

    /**
     * 取得關聯的員工卡片
     */
    public function staffCard(): BelongsTo
    {
        return $this->belongsTo(StaffCard::class);
    }

    /**
     * 取得刷卡的機台
     */
    public function machine(): BelongsTo
    {
        return $this->belongsTo(Machine::class);
    }

    /**
     * 取得關聯的訂單
     */
    public function order(): BelongsTo
    {
        return $this->belongsTo(\App\Models\Transaction\Order::class);
    }
}
