<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class CierreTurno extends Model
{
    use HasFactory;

    protected $table = 'cierres_turno';
    protected $primaryKey = 'id_cierre';
    public $timestamps = false;

    protected $fillable = [
        'id_usuario',
        'id_turno',
        'fecha',
        'total_ventas',
        'efectivo',
        'credito',
        'visa',
        'descuentos',
        'diferencia',
    ];

    protected $casts = [
        'fecha' => 'date',
        'total_ventas' => 'decimal:2',
        'efectivo' => 'decimal:2',
        'credito' => 'decimal:2',
        'visa' => 'decimal:2',
        'descuentos' => 'decimal:2',
        'diferencia' => 'decimal:2',
    ];

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

    public function turno()
    {
        return $this->belongsTo(Turno::class, 'id_turno', 'id_turno');
    }
}
