diff --git a/src/Query/ScoutBuilder.php b/src/Query/ScoutBuilder.php index 0621a3f..d264e79 100644 --- a/src/Query/ScoutBuilder.php +++ b/src/Query/ScoutBuilder.php @@ -118,9 +118,12 @@ public function sort($field, $direction = 'asc') } /** - * Apply multiple sorts to the query builder. + * Apply multiple sort directives to the underlying query builder. * - * @param array $sorts An array of sorts to apply. + * Each element must be an array with a 'field' key and an optional 'direction' key + * (defaults to 'asc'); each directive is forwarded to sort(). + * + * @param array $sorts Array of sort directives. */ public function applySorts($sorts) { @@ -129,6 +132,15 @@ public function applySorts($sorts) } } + /** + * Apply soft-delete visibility to the underlying Scout query builder. + * + * Sets the query to include only soft-deleted records when `$trashed` is `"only"`, + * or to include both deleted and non-deleted records when `$trashed` is `"with"`. + * Any other value is ignored (no change). + * + * @param string $trashed One of: "only" (only trashed), "with" (include trashed), or other (no-op). + */ public function applyTrashed(string $trashed): void { if ($trashed === 'only') { diff --git a/src/Rules/Search/SearchText.php b/src/Rules/Search/SearchText.php index f913a41..765ee60 100644 --- a/src/Rules/Search/SearchText.php +++ b/src/Rules/Search/SearchText.php @@ -7,6 +7,20 @@ class SearchText extends RestRule { + /** + * Build Laravel validation rules for a search input attribute. + * + * Returns rules that either prohibit the attribute when the resource is not model-searchable, + * or validate a nested search payload structure when searchable: + * - ``: optionally present and must be an array. + * - `.value`: nullable string (the search text). + * - `.trashed`: must be one of `'with'` or `'only'`. + * + * @param string $attribute The root attribute name to validate (e.g. "search"). + * @param mixed $value Unused by this rule builder; present to match the rule interface. + * + * @return array> Laravel validation rules keyed by attribute path. + */ public function buildValidationRules(string $attribute, mixed $value): array { if (!$this->resource->isModelSearchable()) {