PHP code example of cleaniquecoders / global-search

1. Go to this page and download the library: Download cleaniquecoders/global-search library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cleaniquecoders / global-search example snippets



use CleaniqueCoders\GlobalSearch\GlobalSearch;

GlobalSearch::routes();

// get the first result
search(\App\Models\User::class, 'nasrul');

// get all possible result by passing true to the third argument
// this will return a paginated result
search(\App\Models\User::class, 'nasrul', true);



namespace App\Enums;

use Spatie\Enum\Laravel\Enum;

/**
 * @method static self user()
 * @method static self profile()
 */
class SearchType extends Enum
{
    public static function values(): array
    {
        return [
            'user' => \App\Models\User::class,
            'profile' => \App\Models\Profile::class,
        ];
    }

    protected static function labels(): array
    {
        return [
            'user' => __('User'),
            'profile' => __('Profile'),
        ];
    }
}
bash
php artisan vendor:publish --tag="global-search-config"