<?php
namespace App\Typeahead;
use App\Models\Genre;
class GenreTypeahead extends TypeaheadBuilder
{
public function get($total = 10)
{
$query = Genre::where('name', 'LIKE', '%'.$this->search_string.'%');
if ($this->exclude) {
$query = $query->whereNotIn('id', $this->exclude);
}
$this->data = $query->take($total)
->pluck('name', 'id');
return $this->output();
}
}