heseya/laravel-searchable
Larablocks Analysis
heseya/laravel-searchable works with Laravel 7, 8 and 9 (latest release 2.0.0, Mar 14, 2022), all past end of life (the last on Feb 6, 2024): no more fixes, even for security.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 7, 8 and 9, past end of life since Feb 6, 2024
- No release in the last 12 months (last: Mar 14, 2022)
- 31 downloads a month (needs 10,000)
- 2 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Mar 14, 2022.
- No releases in the last 12 months.
- First released: Aug 14, 2020.
- Monthly downloads: 31.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 5, 2026.
| Install | |
|---|---|
composer require heseya/laravel-searchable |
|
| Latest Version: | 2.0.0 |
| PHP: | >=7.3 |
| Laravel: | 7 · 8 · 9 |
| License: | MIT |
| Last Updated: | Mar 14, 2022 |
| Links: | GitHub · Packagist |
Heseya\Searchable
🔍 Search trait for Eloquent models.
Installation
$ composer require heseya/laravel-searchables
How to use it?
class User extends Model
{
use HasCriteria;
protected $criteria = [
'id', // default criterion
'email' => Equals::class,
'name' => Like::class,
'description' => Custom::class,
];
}
class Controller
{
function index(Request $request)
{
User::searchByCriteria([
'email' => 'example@example.com',
'name' => 'John'
])->get();
// you can extend query
User::searchByCriteria($request->all())
->where('public', true)
->get();
}
}
Available criteria
- Equals
- Like
Custom criterion
final class CustomCriterion extends Criterion
{
public function query(Builder $query): Builder
{
// do whatever you want
return $query;
}
}
Change default criterion in model
class User extends Model
{
protected function getDefaultCriterion(): string
{
return Equals::class;
}
}
Testing
To run the tests, run the following command from the project folder.
$ composer test
License
Package released under the MIT License. See the LICENSE file for details.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 2.0.0 | >=7.3 | >=7.0 | MIT | |
| 1.0.0 | >=7.3 | >=7.0 | MIT |