<?php

declare(strict_types=1);

namespace App\Models\Market;

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

class ProductTransactionSessionArchive extends Model
{
    protected ?string $table = 'prd_trx_ses_arc';

    /**
     * The primary key for the model.
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the IDs are auto-incrementing.
     */
    public $incrementing = true;

    /**
     * The "type" of the primary key.
     */
    protected $keyType = 'int';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [
        'name',
        'description',
        'details',
        'hashkey',
        'transactions_sessions_id',
        'created_by',
        'updated_by',
        'created_for',
        'transactions_snapshot'
    ];

    protected array $casts = [
        'details' => 'array',
        'transactions_snapshot' => 'array',
    ];

    /**
     * Relationships.
     */
    public function transactionSession()
    {
        return $this->belongsTo(ProductTransactionSession::class, 'transactions_sessions_id');
    }


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

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

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