<?php

declare(strict_types=1);

namespace App\Models\Market;

use App\Models\Model;
use App\Models\User;

class PosSessionArchive extends Model
{
    protected ?string $table = 'pos_sessions_archive';

    protected array $fillable = [
        'pos_session_id',
        'hashkey',
        'session_snapshot',
        'transactions_snapshot',
        'created_by',
        'updated_by',
        'remarks',
    ];

    protected array $casts = [
        'session_snapshot' => 'array',
        'transactions_snapshot' => 'array',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'pos_session_id' => 'integer',
    ];

    /**
     * Relationships
     */
    public function session()
    {
        return $this->belongsTo(PosSession::class, 'pos_session_id');
    }

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

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