hassamulhaq/laravel-model-relation-search

Laravel package to search via your models and model relations.

0.0.1 2023-03-28 13:44 UTC

This package is not auto-updated.

Last update: 2025-05-07 21:43:45 UTC


README

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);
  }