Provides the searching trait for Laravel Eloquent models.
This package has been developed by Markus Lind. Visit me at vskut.ru.
Via composer:
$ composer require vskut/laravel5-model-searchable
use vskut\laravel5ModelSearchable\Searchable;
class User extends Model
{
use Searchable;
}
class UserController
{
public function index()
{
$user = User::searchable(request()->get('search'), ['id', 'email', 'username'])
->get();
return view('user.index', compact('user'));
}
}
<form action="{{ route('user.index') }}" method="get">
<input type="text" name="search" value="{{ request()->get('search') }}">
<button type="submit">Search</button>
</form>
The MIT License (MIT).