PHP code example of aviator / eloquent-search-map

1. Go to this page and download the library: Download aviator/eloquent-search-map 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/ */

    

aviator / eloquent-search-map example snippets


$model::when($request->something, function (Builder $query) {
    return $query->where('column', 'like', '%' . $request->something . '%'); 
})->get();

$model::search(['something', 'otherthing'])->get();

'providers' => [
    ...
    Aviator\Search\ServiceProvider::class,
],

class User extends Model implements Searchable
{
    use SearchableTrait;
   
    // ..etc
}

protected $searches = [
    'email'
];

protected $searches = [
    'alias' => 'email'
];

$model::search(['email' => 'user_email'])->get();

$model::search(['term'], $request)->get();

protected $searches = [
    'relation.column'
];

$users = User::search(['company.city'])->get();

$users = User::search(['company.city' => 'city'])->get();