2017 © Pedro Peláez
 

library eloquent-search

A simple search package for Eloquent.

image

ac-developers/eloquent-search

A simple search package for Eloquent.

  • Tuesday, July 24, 2018
  • by tsommie
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Eloquent Search

Easy way to search for a keyword in all your eloquent models at once., (*1)

Note:This package does not support any search driver like ElasticSearch or Agolia, (*2)

1. Installation

The recommended way to install eloquent search is by using composer., (*3)

Run:, (*4)

composer require ac-developers/eloquent-search

2. Usage

Implement the EloquentSearchInterface in your eloquent model and then also use the EloquentSearchTrait, this will require you to implement a searchColumns method which should return an array of the columns you would want to search through in the model., (*5)

class Article implements EloquentSearchInterface
{
    use EloquentSearchTrait;

    /**
     * Return an array of all the columns to search through.
     *
     * @return array
     */
    public function searchColumns():array
    {
        return ['title', 'body', 'summary];
    }
}

Then in your controller you would use the the EloquentSearch class to find what your looking for. The class takes 5 arguments, but the most important is the first which is the keyword you want to search for and then the second is an array of all the eloquent model classes you would like to search through., (*6)

class SearchController extends Controller
{
    /**
     * @param Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Support\HtmlString|\Illuminate\View\View
     */
    public function __invoke(Request $request)
    {
        $result = EloquentSearch::search($request->get('q'),[
            Article::class, Users:class, Blog::class 
        ]);
    }
}

The EloquentSearch class will merge and return a paginated collection of all the models searched through using the Illuminate\Pagination\LengthAwarePaginator class., (*7)

3. Security Vulnerabilities

If you discover a security vulnerability within Laravel Form Processor, please send an e-mail to Anitche Chisom via anitchec.dev@gmail.com. All security vulnerabilities will be promptly addressed., (*8)

4. License

The Eloquent Search is open-sourced software licensed under the MIT license., (*9)

The Versions

24/07 2018

dev-master

9999999-dev

A simple search package for Eloquent.

  Sources   Download

MIT

The Requires

 

by Anitche Chisom

eloquent search anitche chisom

23/07 2018

v1.1

1.1.0.0

A simple search package for Eloquent.

  Sources   Download

MIT

The Requires

 

by Anitche Chisom

eloquent search anitche chisom

23/07 2018

1.0.x-dev

1.0.9999999.9999999-dev

A simple search package for Eloquent.

  Sources   Download

MIT

The Requires

 

by Anitche Chisom

eloquent search anitche chisom

23/07 2018

2.0.x-dev

2.0.9999999.9999999-dev

A simple search package for Eloquent.

  Sources   Download

MIT

The Requires

 

by Anitche Chisom

eloquent search anitche chisom

23/07 2018

v1.0

1.0.0.0

A simple search package for Eloquent.

  Sources   Download

MIT

The Requires

 

by Anitche Chisom

eloquent search anitche chisom