<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;

class ManyChatPedido extends Model
{
    protected $table = 'manychat_pedidos';

    protected $fillable = [
        'empresa_id',
        'cliente_nombre',
        'telefono',
        'direccion',
        'observaciones',
        'total',
        'estado',
        'origen',
    ];

    protected function casts(): array
    {
        return [
            'total' => 'decimal:2',
            'created_at' => 'datetime',
            'updated_at' => 'datetime',
        ];
    }

    public function empresa(): BelongsTo
    {
        return $this->belongsTo(Empresa::class, 'empresa_id');
    }

    public function detalles(): HasMany
    {
        return $this->hasMany(ManyChatPedidoDetalle::class, 'pedido_id');
    }
}
