Looking to hire Laravel developers? Try LaraJobs

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
Links
Downloads
15

Comments
comments powered by Disqus

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 ModelRelationSearchableTrait trait in your model.
  • Define $searchable_columns property 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);
  }