mozex/laravel-searchable
Add a Searchable trait to any Eloquent model to search multiple columns and related data (relations, morphs, even cross-database) via a single ->search() call. Works with Laravel Scout and includes optional Filament table/global search integration.
Strengths:
where clauses or complex joins.in, include, except) and external query limits for cross-database relations.Limitations:
LIKE '%term%', which is inefficient for large datasets (no index utilization). Requires Scout for scaling.LIKE semantics; lacks advanced features like stemming, synonyms, or fuzzy matching.IN clauses, which can bloat queries.scopeDatabaseSearch).search() methods (e.g., Corcel). Mitigation via applySearch() or trait aliasing.LIKE behavior.LIKE queries on large tables will impact response times. Requires proactive monitoring and Scout migration planning.commentable:post.author.name) may generate verbose SQL, increasing query complexity.databaseSearch() with search()).LIKE performance is unacceptable, even with indexing?pg_trgm (PostgreSQL) or full-text indexes be implemented as a fallback?user:post:author.name)? Will query generation become unwieldy?search() scope be aliased globally (e.g., databaseSearch()) to avoid ambiguity?getGloballySearchableAttributes() alignment.)Post or Product) to test SQL performance and relation queries.where clauses with searchableColumns() where applicable.databaseSearch() to search().searchableAs to maintain backward compatibility during transition.getGloballySearchableAttributes() per resource, aligning with Scout or SQL search.LIKE behavior across production databases (e.g., PostgreSQL pg_trgm vs. MySQL collations).search() in custom builders to delegate to applySearch().scopeSearch conflicts are resolved via trait aliasing.Searchable trait to models and define searchableColumns().Model::search('term')) and chained queries.advancedSearchable() to table columns.SearchableGlobalSearchProvider for global search.author.name).externalLimit if needed for cross-database relations.Searchable trait alongside DatabaseSearchable.databaseSearch() with search() in application code.databaseSearch() in favor of Scout’s search() where applicable.LIKE query performance.tenant_id, status) to reduce LIKE scan scope.pg_trgm indexes for LIKE '%term%' queries.advancedSearchable() macro compatibility.searchableColumns() conventions (e.g., relation paths, morph notation).externalLimit).scopeSearch).getGloballySearchableAttributes() requirements per resource.LIKE queries.externalLimit usage; increase if queries exclude too manyHow can I help you explore Laravel packages today?