bigdropinc/laravel-simple-search

Laravel package for search.
2,585 1
Install
composer require bigdropinc/laravel-simple-search
PHP:>=7.0
License:BSD-3-Clause
Last Updated:Jan 27, 2020
Links: GitHub  ·  Packagist
Maintainer: poprigun

#Laravel Simple Search

##Requirements

Make sure all dependencies have been installed before moving on:

Pull the package via Composer:

The preferred way to install this extension is through composer.

Either run

composer require bigdropinc/laravel-simple-search "1.0.0"

or add

"bigdropinc/laravel-simple-search": "1.0.0"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by:

UserSearch::apply(User:class, request()->all());

Filters

All attributes that should be used described in property fillable

protected $fillable = [
   'id',
   'first_name',
   'last_name',
];

By default for each attribute applied condition =

Example:

protected $fillable = [
   'id',
   'name' => 'first_name', //alias:  name - search attr, first_name - db attr
   'last_name',
];

Equivalent


User::where('first_name', $firstNameValue)
   ->where('last_name', $lastNameValue)
   ->where('id', $userIdValue)

Сustom filters

pulic function id($value) {
   $this->query->where('id', '>', $value);
}

Cast

Used default Laravel attribute casting. By default use string cast

protected $cast = [
  'id' => 'integer',	
];

Sort

Default sort

protected $defaultSort = 'first_name';

Ascending order by first_name: sort=first_name

Descending order by first_name: sort=-first_name | hyphen (-) in the start

Related Packages

sc/scload

Scload Search and Download Form Soundcloud By keywords and link

7 0
mmanos/laravel-search

A search package for Laravel 5.

75,742 350
pmatseykanets/laravel-scout-postgres

PostgreSQL Full Text Search Driver for Laravel Scout

222,525 164
torann/laravel-hunt

Unified search for Laravel models using Elasticsearch.

375 4
teamtnt/laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tnts...

2,821,362 1,134