<?php

namespace App\Livewire;

use App\Models\Album;
use Livewire\Component;

class Buscador extends Component
{
    public $nombre;

    public $resultados = [];

    public function buscar(){
        $this->validate([
            'nombre' => 'required'
        ]);

        $this->resultados = Album::where('Title', 'like', "$this->nombre%")->with('artista')->get();
    }

    public function render()
    {
        return view('livewire.buscador');
    }
}

