Skip to content

Fix search_model handling for dotted columns and query builders#1

Merged
AbdelrhmanSaid merged 1 commit intomasterfrom
codex/find-and-fix-potential-bug
Apr 15, 2026
Merged

Fix search_model handling for dotted columns and query builders#1
AbdelrhmanSaid merged 1 commit intomasterfrom
codex/find-and-fix-potential-bug

Conversation

@AbdelrhmanSaid
Copy link
Copy Markdown
Contributor

Motivation

  • Prevent runtime errors when search_model is called with a base QueryBuilder (non-Eloquent) or when dotted columns reference no relation on the model.
  • Ensure the function return type matches the accepted input types to avoid type mismatches.
  • Provide a safe fallback for dotted-column searches on non-Eloquent queries so search remains usable across different query types.

Description

  • Updated search_model return type to Builder|QueryBuilder to match the accepted input signature in src/helpers.php.
  • Changed the internal relation handler signature to accept Builder|QueryBuilder and added a void return type.
  • When a dotted column is encountered, call orWhereHas only if the query is an Eloquent Builder and the relation method exists on the model; otherwise fall back to a plain orWhere on the column.
  • Kept single-file change confined to src/helpers.php and preserved original behavior for non-dotted columns.

Testing

  • Ran php -l src/helpers.php and it reported no syntax errors (success).
  • Attempted ./vendor/bin/pint --test src/helpers.php but the pint tool is not installed in this environment (skipped).

Codex Task

@AbdelrhmanSaid AbdelrhmanSaid merged commit 783ade0 into master Apr 15, 2026
1 check passed
@AbdelrhmanSaid AbdelrhmanSaid deleted the codex/find-and-fix-potential-bug branch April 15, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant