<?php

namespace Koneko\SatCatalogs\Models;

use Illuminate\Database\Eloquent\Model;

class Moneda extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'sat_moneda';

    /**
     * The attributes that are mass assignable.
     *
     * @var string[]
     */
    protected $fillable = [
        'c_moneda',
        'descripcion',
        'decimales',
        'porcentaje_variacion',
        'fecha_inicio_vigencia',
        'fecha_fin_vigencia',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'fecha_inicio_vigencia' => 'datetime',
        'fecha_fin_vigencia' => 'datetime',
    ];


    public static function selectList()
    {
        return self::selectRaw('c_moneda, CONCAT_WS(" ", c_moneda, "-", descripcion) as text')
            ->pluck('text', 'c_moneda');
    }
}
