LaravelPackages.net
Acme Inc.
Toggle sidebar
hnhdigital-os/laravel-model-search

Query a model.

293
3
3.0.2
About hnhdigital-os/laravel-model-search

hnhdigital-os/laravel-model-search is a Laravel package for query a model.. It currently has 3 GitHub stars and 293 downloads on Packagist (latest version 3.0.2). Install it with composer require hnhdigital-os/laravel-model-search. Discover more Laravel packages by hnhdigital-os or browse all Laravel packages to compare alternatives.

Last updated

___  ___          _      _ _____                     _     
|  \/  |         | |    | /  ___|                   | |    
| .  . | ___   __| | ___| \ `--.  ___  __ _ _ __ ___| |__  
| |\/| |/ _ \ / _` |/ _ \ |`--. \/ _ \/ _` | '__/ __| '_ \ 
| |  | | (_) | (_| |  __/ /\__/ /  __/ (_| | | | (__| | | |
\_|  |_/\___/ \__,_|\___|_\____/ \___|\__,_|_|  \___|_| |_|
                                                           

Search a model by providing an array of attributes. Correctly builds relationships and the appropiate query. Provides inline operaters for improved user searching.

Latest Stable Version Total Downloads Latest Unstable Version Built for Laravel License Donate to this project using Patreon

This package has been developed by H&H|Digital, an Australian botique developer. Visit us at hnh.digital.

Documentation

Requirements

  • PHP 8.0.2
  • Laravel 9

Install

Via composer:

$ composer require hnhdigital-os/laravel-model-search ~3.0

Configuration

Enable the trait on any given model.

use HnhDigital\ModelSearch\ModelTrait as ModelSearchTrait;

class SomeModel extends Model
{
    use ModelSearchTrait;
}

Usage

A simple search could be:

SomeModel::search(['title' => 'Test']);
SomeModel::search(['title' => [['=', 'Test']]]);
SomeModel::search(['title' => '= Test']);
SomeModel::search(['title' => '!= Test']);

For a better look at what is possible, check out the tests/ModelTest.php test case for an extensive list of possiblities.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Star History Chart