PHP code example of craftcodery / laravel-searchable
1. Go to this page and download the library: Download craftcodery/laravel-searchable 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/ */
craftcodery / laravel-searchable example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use CraftCodery\Searchable\Searchable;
class User extends Model
{
use Searchable;
/**
* Get the searchable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
return [
'columns' => [
'users.name' => 60,
'users.email' => 60,
'locations.city' => 40,
],
'joins' => [
'locations' => [
'users.location_id',
'locations.id'
],
],
'groupBy' => 'users.id'
];
}
}