PHP Classes

Laravel PHP Global Search: Provide search capabilities to data objects

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 69 All time: 10,132 This week: 190Up
Version License PHP version Categories
laravel-global-searc 1.0.0The PHP License5PHP 5, Databases, Searching, Libraries
Description 

Author

This package can provide search capabilities to data objects.

It provides a trait that can be used by an class of data objects so when information needs to be searched, the trait will access variables of that class to determine how the data object information can be searched.

The data object class variables need to inform the list of fields that can be used to search information, sort results, as well parameters to compose search queries.

Innovation Award
PHP Programming Innovation award nominee
January 2019
Number 4
Laravel is a very popular PHP framework that supports modern design patterns, PHP standard specifications and more recent PHP language features.

This package uses Laravel to implement a global search interface to any class using a trait to simplify searching for data objects information stored in a database.

Manuel Lemos
Picture of Nyi Nyi Lwin
  Performance   Level  
Name: Nyi Nyi Lwin <contact>
Classes: 11 packages by
Country: Myanmar Myanmar
Innovation award
Innovation award
Nominee: 6x

Winner: 3x

Details

Laravel Global Search [WIP]

Laravel Global Search

Latest Stable Version Total Downloads License

Installation

composer require php-junior/laravel-global-search

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

PhpJunior\LaravelGlobalSearch\LaravelGlobalSearchProvider::class,

php artisan vendor:publish --provider="PhpJunior\LaravelGlobalSearch\LaravelGlobalSearchProvider"

This is the contents of the published config file:

return [
    'resources' => [
        \App\Models\Auth\User::class
    ],
    'limit' => 10
];

Usage

First <code>PhpJunior\LaravelGlobalSearch\Traits\GlobalSearchable</code> trait to models

use PhpJunior\LaravelGlobalSearch\Traits\GlobalSearchable;

class User extends Authenticatable
{
    use GlobalSearchable;
    
    /
     * The columns that should be searched.
     *
     * @var array
     */
    protected  $search = [
        'name', 'email',
    ];

    /
     * The columns that should be displayed.
     *
     * @var array
     */
    protected $only = [
        'name', 'email'
    ];

    /
     * The columns that should be ordered.
     *
     * @var array
     */
    protected  $order = [
        'name' => 'desc',
        'email' => 'asc'
    ];

    // Optional
    protected $searchQuery = [
        [
            'method' => 'where',
            'column' => 'email',
            'operator' => '=',
            'value' => 'usern@user.com'
        ],
        [
            'method' => 'whereBetween',
            'column' => 'votes',
            'value' => [1, 100]
        ]
    ];

    /
     * @var string
     */
    protected $searchIndex = 'users-index';
}

Search

LaravelGlobalSearch::search($text)

Credits

  • All Contributors

License

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

  Files folder image Files  
File Role Description
Files folder imageconfig (1 file)
Files folder imagesrc (1 file, 3 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  config  
File Role Description
  Plain text file laravel-global-search.php Class Class source

  Files folder image Files  /  src  
File Role Description
Files folder imageFacades (1 file)
Files folder imageServices (1 file)
Files folder imageTraits (1 file)
  Plain text file LaravelGlobalSearchProvider.php Class Class source

  Files folder image Files  /  src  /  Facades  
File Role Description
  Plain text file LaravelGlobalSearch.php Class Class source

  Files folder image Files  /  src  /  Services  
File Role Description
  Plain text file LaravelGlobalSearch.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file GlobalSearchable.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:69
This week:0
All time:10,132
This week:190Up