laravel-model-relation-search maintained by hassamulhaq
Description
Laravel package to search via your models and model relations.
Author
Last update
2023/03/28 15:58
(dev-main)
License
Downloads
15
Laravel Model and Model Relation Search
Laravel package to search via your models and model relations.
installation :
composer required hassamulhaq/laravel-model-relation-search
Usage :
- Use
ModelRelationSearchableTraittrait in your model. - Define
$searchable_columnsproperty in your model to select which columns to search in.
Example :
use HassamUlHaq\LaravelModelRelationSearch\ModelRelationSearchableTrait;
class Book extends Model
{
use ModelRelationSearchableTrait;
protected $searchable_columns = [
'title',
'author.bio',
//'author.companies.name'
];
public function authors()
{
return $this->hasOne(Author::class);
}