this package is facility the search in model with complex relations
You can install the package via composer:
composer require osamaalmamri/laravel-searchYou can publish the config file with:
php artisan vendor:publish --tag="laravel-search-config"This is the contents of the published config file:
return [
// this is the key namein Request $request
'key' => "search"
];in the modal we use searchable class
use OsamaAlmamri\LaravelSearch\Searchable;
class YourModal extends Model
{
use Searchable;
// define the name of cols
//if you need search in another fields of another table using the relation name then col name
// you can search any related relation as the following
public $searchable = ['name','description','user.name','user.phone','user.role.name'];
}The MIT License (MIT). Please see License File for more information.