New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

bigdropinc/laravel-simple-search

Laravel package for search.
2,606 1
Install
composer require bigdropinc/laravel-simple-search:dev-master
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

emilmoe/fullsearch

A full page search screen.

1,009 0
sc/scload

Scload Search and Download Form Soundcloud By keywords and link

7 0
simianbv/search

A utility package that works on top of laravel.

7,824 0
technote/laravel-search-helper

Search helper for laravel

5,658 2
custom-d/hashed-search

A hashed search package for adding a searchable hash to your encrypted database...

2,649 3