<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Obras_adicionales;

class ShowServicios extends Component
{
    public $servicios;

    public $descripcion, $resolucion, $monto;

    public function mount()
    {
        $this->servicios = Obras_adicionales::all();
    }

    public function render()
    {
        return view('livewire.show-servicios');
    }

    public function servicioCreate()
    {
        $this->validate([
            'descripcion' => 'required',
            'resolucion' => 'required',
            'monto' => 'required',
        ]);

        Obras_adicionales::create([
            'descripcion' => $this->descripcion,
            'resolucion' => $this->resolucion,
            'monto' => $this->monto,
        ]);

        $this->descripcion = '';
        $this->resolucion = '';
        $this->monto = '';

        $this->emit('servicioAdd');
        $this->emit('closeModal');
        $this->mount();
    }
}
