https://github.com/vskut/laravel5-model-searchable
Search scope for laravel models
https://github.com/vskut/laravel5-model-searchable
eloquent-models laravel laravel-framework laravel5 php php7 search searchable
Last synced: about 1 year ago
JSON representation
Search scope for laravel models
- Host: GitHub
- URL: https://github.com/vskut/laravel5-model-searchable
- Owner: VSKut
- Created: 2019-05-23T21:54:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-23T22:45:04.000Z (about 7 years ago)
- Last Synced: 2025-03-24T15:11:34.327Z (about 1 year ago)
- Topics: eloquent-models, laravel, laravel-framework, laravel5, php, php7, search, searchable
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel 5 Model Trait Searchable
Provides the searching trait for Laravel Eloquent models.
This package has been developed by Markus Lind. Visit me at [vskut.ru](http://vskut.ru).
## Install
Via composer:
`$ composer require vskut/laravel5-model-searchable`
## Usage
### Model
```php
use vskut\laravel5ModelSearchable\Searchable;
class User extends Model
{
use Searchable;
}
```
### Controller
```php
class UserController
{
public function index()
{
$user = User::searchable(request()->get('search'), ['id', 'email', 'username'])
->get();
return view('user.index', compact('user'));
}
}
```
### View
```html
Search
```
## Credits
* [Markus Lind](https://github.com/vskut)
* [All Contributors](https://github.com/vskut/laravel5-model-searchable/contributors)
## License
The MIT License (MIT).