<?php

namespace App\FiveM\Models\ESX;

use Illuminate\Database\Eloquent\Model;

/**
 * Maps to ESX Legacy's `users` table: identifier (PK), license, name,
 * money (int, "cash" account), job, job_grade, group, position (json),
 * metadata (json), inventory (json). Bank/black_money in ESX are commonly
 * tracked in a separate `addon_account_data` table rather than a column on
 * `users` — see ESXAdapter::adjustMoney() for how that's handled.
 */
class Player extends Model
{
    protected $connection = 'fivem';

    protected $primaryKey = 'identifier';

    public $incrementing = false;

    protected $keyType = 'string';

    public $timestamps = false;

    protected function casts(): array
    {
        return [
            'position' => 'array',
            'metadata' => 'array',
            'inventory' => 'array',
        ];
    }

    public function getTable()
    {
        return config('fivem.tables.esx.players', 'users');
    }
}
