2017 © Pedro Peláez
 

library eloquentsearch

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

image

assemble/eloquentsearch

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  • Thursday, March 29, 2018
  • by AlexBlake
  • Repository
  • 1 Watchers
  • 1 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Eloquent Model Searcher for Laravel 5

Installation

Add this line to your providers array: ``` php Assemble\EloquentSearch\EloquentSearchServiceProvider::class,, (*1)


Add this line to your `aliases` array: ``` php 'EloquentSearch' => Assemble\EloquentSearch\Facades\EloquentSearcher::class,

You will need to run php artisan vendor:publish to publish the config file to your instalation, Once run, you can find it in config/eloquenet_search.php. This config file is used to controll which models are used to search/return entities of., (*2)

Configuration

The config file can be found in the laravel config folder at config/eloquent_search.php, here you can define the classes related to your models as below. ``` php return [ 'search_models' => [ /* Add your searchable eloquent models here, this is an example of user model usage., (*3)

        If you have your models sitting in the app root as default, something like this should find them.

            'user' => User::class,

        Otherwise if you have them elsewhere or the application cant seem to find them, try prefix them as such.

            'user' => App\Models\User::class,

    */

    'user' => User::class,

]

];, (*4)



## Usage To make use of the search functionality, you will need to implement a `$searchable` property on your models to detail which fields and relations are searchable. ```php /* * Searchable Fields */ public $searchable = [ 'name', 'user_id', // fields 'user', 'tags', // relations ];

You can also implement the method 'isSearchable' in your models for the searcher to determine if it is allowed to search/return that model. php public function isSearchable(){ // Do your checks to determine if the model may be searched by the user return true; } This feature lets you restrict user searches to only the models they are allowed to see., (*5)

The Versions

29/03 2018

dev-master

9999999-dev

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  Sources   Download

MIT

The Requires

 

by Alex Blake

29/03 2018

1.5.0

1.5.0.0

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  Sources   Download

MIT

The Requires

 

by Alex Blake

15/02 2018

v1.4.1

1.4.1.0

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  Sources   Download

MIT

by Alex Blake

02/03 2016

v1.4

1.4.0.0

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  Sources   Download

MIT

by Alex Blake

24/02 2016

v1.3

1.3.0.0

Search and retrieve an eloquent model entity based on complex search criteria from the model relations.

  Sources   Download

MIT

by Alex Blake