<?php

namespace App\FiveM\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * Targets a single-table `jobs` (name, label, grades json) convention —
 * the shape qbx_core and many custom QBCore forks use when jobs are
 * mirrored into the database for admin editing rather than defined only in
 * shared.lua. If a server keeps grades in a separate `job_grades` table
 * instead, adjust this model's accessors rather than the admin controller.
 */
class JobDefinition extends Model
{
    protected $connection = 'fivem';

    protected $primaryKey = 'name';

    public $incrementing = false;

    protected $keyType = 'string';

    public $timestamps = false;

    protected $fillable = ['name', 'label', 'grades'];

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

    public function getTable()
    {
        return config('fivem.tables.'.config('fivem.framework').'.jobs', 'jobs');
    }
}
