<?php

namespace App\Livewire;

use App\Models\Material;
use Livewire\Component;
use Livewire\Attributes\On;

class ModalMaterias extends Component
{
    public $material = null;
    public $carrera;

    #[On('edit-material')]
    public function editMaterial($id)
    {
        $this->material = Material::findOrFail($id);

        $this->dispatch('open-material-modal');
    }

    #[On('create-material')]
    public function createMaterial()
    {
        $this->reset('material');
        $this->dispatch('open-material-modal');
    }

    public function render()
    {
        return view('livewire.modal-materias');
    }
}
