From 34af23afaaa04716184e688471620602e8f29ee7 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 6 Jul 2023 22:05:38 +0100 Subject: [PATCH] Make "callback" parameter names more specific --- packages/forms/.stubs.php | 2 +- packages/forms/docs/03-fields/03-select.md | 34 +++++++++---------- .../forms/docs/03-fields/06-checkbox-list.md | 4 +-- packages/forms/docs/05-validation.md | 4 +-- .../forms/src/Components/CheckboxList.php | 10 +++--- .../Components/Concerns/CanBeValidated.php | 16 ++++----- ...EntanglesStateWithSingularRelationship.php | 6 ++-- packages/forms/src/Components/Select.php | 28 +++++++-------- packages/forms/src/Concerns/HasComponents.php | 10 +++--- packages/forms/src/Testing/TestsForms.php | 8 ++--- ...EntanglesStateWithSingularRelationship.php | 4 +-- packages/panels/src/FilamentManager.php | 4 +-- .../src/Panel/Concerns/HasRenderHooks.php | 4 +-- .../Commands/Concerns/CanValidateInput.php | 6 ++-- .../support/src/Concerns/Configurable.php | 6 ++-- .../src/Filters/Concerns/HasRelationship.php | 6 ++-- 16 files changed, 76 insertions(+), 76 deletions(-) diff --git a/packages/forms/.stubs.php b/packages/forms/.stubs.php index d385bb508e..15b0baa3fe 100644 --- a/packages/forms/.stubs.php +++ b/packages/forms/.stubs.php @@ -15,7 +15,7 @@ namespace Livewire\Testing { public function assertFormExists(string $name = 'form'): static {} - public function assertFormFieldExists(string $fieldName, string | Closure $formName = 'form', ?Closure $callback = null): static {} + public function assertFormFieldExists(string $fieldName, string | Closure $formName = 'form', ?Closure $checkFieldUsing = null): static {} public function assertFormFieldIsDisabled(string $fieldName, string $formName = 'form'): static {} diff --git a/packages/forms/docs/03-fields/03-select.md b/packages/forms/docs/03-fields/03-select.md index dda608c29e..cf520c8ade 100644 --- a/packages/forms/docs/03-fields/03-select.md +++ b/packages/forms/docs/03-fields/03-select.md @@ -106,10 +106,10 @@ You may employ the `relationship()` method of the `Select` to configure a `Belon use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ``` -The `multiple()` method may be used in combination with `relationship()` to use a `BelongsToMany` relationship. Filament will load the options from the relationship, and save them back to the relationship's pivot table when the form is submitted. If a `relationshipName` is not provided, Filament will use the field name as the relationship name: +The `multiple()` method may be used in combination with `relationship()` to use a `BelongsToMany` relationship. Filament will load the options from the relationship, and save them back to the relationship's pivot table when the form is submitted. If a `name` is not provided, Filament will use the field name as the relationship name: ```php use Filament\Forms\Components\Select; @@ -127,7 +127,7 @@ By default, if the select is also searchable, Filament will return search result use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable(['name', 'email']) ``` @@ -139,7 +139,7 @@ If you'd like to populate the searchable options from the database when the page use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->preload() ``` @@ -154,9 +154,9 @@ use Illuminate\Database\Eloquent\Builder; Select::make('author_id') ->relationship( - relationshipName: 'author', + name: 'author', titleAttribute: 'name', - modifyOptionsQueryUsing: fn (Builder $query) => $query->withTrashed(), + modifyQueryUsing: fn (Builder $query) => $query->withTrashed(), ) ``` @@ -172,7 +172,7 @@ $table->string('full_name')->virtualAs('concat(first_name, \' \', last_name)'); use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'full_name') + ->relationship(name: 'author', titleAttribute: 'full_name') ``` Alternatively, you can use the `getOptionLabelFromRecordUsing()` method to transform an option's Eloquent model into a label: @@ -184,8 +184,8 @@ use Illuminate\Database\Eloquent\Model; Select::make('author_id') ->relationship( - relationshipName: 'author', - modifyOptionsQueryUsing: fn (Builder $query) => $query->orderBy('first_name')->orderBy('last_name'), + name: 'author', + modifyQueryUsing: fn (Builder $query) => $query->orderBy('first_name')->orderBy('last_name'), ) ->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->first_name} {$record->last_name}") ->searchable(['first_name', 'last_name']) @@ -200,7 +200,7 @@ use Filament\Forms\Components\Select; use Illuminate\Database\Eloquent\Model; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->createOptionForm([ Forms\Components\TextInput::make('name') ->required(), @@ -225,7 +225,7 @@ use Filament\Forms\Components\Select; use Illuminate\Database\Eloquent\Model; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->editOptionAction([ Forms\Components\TextInput::make('name') ->required(), @@ -401,7 +401,7 @@ When you're using a searchable select or multi-select, you may want to display a use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->loadingMessage('Loading authors...') ``` @@ -414,7 +414,7 @@ When you're using a searchable select or multi-select, you may want to display a use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->noSearchResultsMessage('No authors found.') ``` @@ -427,7 +427,7 @@ When you're using a searchable select or multi-select, you may want to display a use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable(['name', 'email']) ->searchPrompt('Search authors by their name or email address') ``` @@ -440,7 +440,7 @@ When you're using a searchable select or multi-select, you may want to display a use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->searchingMessage('Searching authors...') ``` @@ -453,7 +453,7 @@ By default, Filament will wait 1000 milliseconds (1 second) before searching for use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->searchDebounce(500) ``` @@ -468,7 +468,7 @@ You can limit the number of options that are displayed in a searchable select or use Filament\Forms\Components\Select; Select::make('author_id') - ->relationship(relationshipName: 'author', titleAttribute: 'name') + ->relationship(name: 'author', titleAttribute: 'name') ->searchable() ->optionsLimit(20) ``` diff --git a/packages/forms/docs/03-fields/06-checkbox-list.md b/packages/forms/docs/03-fields/06-checkbox-list.md index b51265746c..f87a617690 100644 --- a/packages/forms/docs/03-fields/06-checkbox-list.md +++ b/packages/forms/docs/03-fields/06-checkbox-list.md @@ -127,7 +127,7 @@ use Illuminate\Database\Eloquent\Builder; CheckboxList::make('technologies') ->relationship( titleAttribute: 'name', - modifyOptionsQueryUsing: fn (Builder $query) => $query->withTrashed(), + modifyQueryUsing: fn (Builder $query) => $query->withTrashed(), ) ``` @@ -155,7 +155,7 @@ use Illuminate\Database\Eloquent\Model; CheckboxList::make('authors') ->relationship( - modifyOptionsQueryUsing: fn (Builder $query) => $query->orderBy('first_name')->orderBy('last_name'), + modifyQueryUsing: fn (Builder $query) => $query->orderBy('first_name')->orderBy('last_name'), ) ->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->first_name} {$record->last_name}") ``` diff --git a/packages/forms/docs/05-validation.md b/packages/forms/docs/05-validation.md index 311503f0dc..959e2ef4f7 100644 --- a/packages/forms/docs/05-validation.md +++ b/packages/forms/docs/05-validation.md @@ -191,7 +191,7 @@ You can further customize the rule by passing a [closure](advanced#closure-custo use Illuminate\Validation\Rules\Exists; Field::make('invitation') - ->exists(callback: function (Exists $rule) { + ->exists(modifyRuleUsing: function (Exists $rule) { return $rule->where('is_active', 1); }) ``` @@ -436,7 +436,7 @@ You can further customize the rule by passing a [closure](advanced#closure-custo use Illuminate\Validation\Rules\Unique; Field::make('email') - ->unique(callback: function (Unique $rule) { + ->unique(modifyRuleUsing: function (Unique $rule) { return $rule->where('is_active', 1); }) ``` diff --git a/packages/forms/src/Components/CheckboxList.php b/packages/forms/src/Components/CheckboxList.php index fdbb3d38d8..485603353b 100644 --- a/packages/forms/src/Components/CheckboxList.php +++ b/packages/forms/src/Components/CheckboxList.php @@ -113,18 +113,18 @@ class CheckboxList extends Field implements Contracts\HasNestedRecursiveValidati return 'deselectAll'; } - public function relationship(string | Closure | null $relationshipName, string | Closure | null $titleAttribute, ?Closure $modifyOptionsQueryUsing = null): static + public function relationship(string | Closure | null $name, string | Closure | null $titleAttribute, ?Closure $modifyQueryUsing = null): static { - $this->relationship = $relationshipName ?? $this->getName(); + $this->relationship = $name ?? $this->getName(); $this->relationshipTitleAttribute = $titleAttribute; - $this->options(static function (CheckboxList $component) use ($modifyOptionsQueryUsing): array { + $this->options(static function (CheckboxList $component) use ($modifyQueryUsing): array { $relationship = $component->getRelationship(); $relationshipQuery = $relationship->getRelated()->query(); - if ($modifyOptionsQueryUsing) { - $relationshipQuery = $component->evaluate($modifyOptionsQueryUsing, [ + if ($modifyQueryUsing) { + $relationshipQuery = $component->evaluate($modifyQueryUsing, [ 'query' => $relationshipQuery, ]) ?? $relationshipQuery; } diff --git a/packages/forms/src/Components/Concerns/CanBeValidated.php b/packages/forms/src/Components/Concerns/CanBeValidated.php index c363bf2486..4430b60bfc 100644 --- a/packages/forms/src/Components/Concerns/CanBeValidated.php +++ b/packages/forms/src/Components/Concerns/CanBeValidated.php @@ -168,16 +168,16 @@ trait CanBeValidated return $this; } - public function exists(string | Closure | null $table = null, string | Closure | null $column = null, ?Closure $callback = null): static + public function exists(string | Closure | null $table = null, string | Closure | null $column = null, ?Closure $modifyRuleUsing = null): static { - $this->rule(static function (Field $component, ?string $model) use ($callback, $column, $table) { + $this->rule(static function (Field $component, ?string $model) use ($column, $modifyRuleUsing, $table) { $table = $component->evaluate($table) ?? $model; $column = $component->evaluate($column) ?? $component->getName(); $rule = Rule::exists($table, $column); - if ($callback) { - $rule = $component->evaluate($callback, [ + if ($modifyRuleUsing) { + $rule = $component->evaluate($modifyRuleUsing, [ 'rule' => $rule, ]) ?? $rule; } @@ -501,9 +501,9 @@ trait CanBeValidated return $this->fieldComparisonRule('same', $statePath, $isStatePathAbsolute); } - public function unique(string | Closure | null $table = null, string | Closure | null $column = null, Model | Closure $ignorable = null, ?Closure $callback = null, bool $ignoreRecord = false): static + public function unique(string | Closure | null $table = null, string | Closure | null $column = null, Model | Closure $ignorable = null, bool $ignoreRecord = false, ?Closure $modifyRuleUsing = null): static { - $this->rule(static function (Field $component, ?string $model) use ($callback, $column, $ignorable, $table, $ignoreRecord) { + $this->rule(static function (Field $component, ?string $model) use ($column, $ignorable, $ignoreRecord, $modifyRuleUsing, $table) { $table = $component->evaluate($table) ?? $model; $column = $component->evaluate($column) ?? $component->getName(); $ignorable = ($ignoreRecord && ! $ignorable) ? @@ -519,8 +519,8 @@ trait CanBeValidated ), ); - if ($callback) { - $rule = $component->evaluate($callback, [ + if ($modifyRuleUsing) { + $rule = $component->evaluate($modifyRuleUsing, [ 'rule' => $rule, ]) ?? $rule; } diff --git a/packages/forms/src/Components/Concerns/EntanglesStateWithSingularRelationship.php b/packages/forms/src/Components/Concerns/EntanglesStateWithSingularRelationship.php index e90467ce14..91c0357a3b 100644 --- a/packages/forms/src/Components/Concerns/EntanglesStateWithSingularRelationship.php +++ b/packages/forms/src/Components/Concerns/EntanglesStateWithSingularRelationship.php @@ -24,10 +24,10 @@ trait EntanglesStateWithSingularRelationship protected ?Closure $mutateRelationshipDataBeforeSaveUsing = null; - public function relationship(string $relationshipName, bool | Closure $condition = true): static + public function relationship(string $name, bool | Closure $condition = true): static { - $this->relationship = $relationshipName; - $this->statePath($relationshipName); + $this->relationship = $name; + $this->statePath($name); $this->loadStateFromRelationshipsUsing(static function (Component | CanEntangleWithSingularRelationships $component) { $component->clearCachedExistingRecord(); diff --git a/packages/forms/src/Components/Select.php b/packages/forms/src/Components/Select.php index 15c006a454..8da421308a 100644 --- a/packages/forms/src/Components/Select.php +++ b/packages/forms/src/Components/Select.php @@ -621,18 +621,18 @@ class Select extends Field implements Contracts\HasAffixActions, Contracts\HasNe return $this->evaluate($this->isSearchable) || $this->isMultiple(); } - public function relationship(string | Closure | null $relationshipName, string | Closure | null $titleAttribute, ?Closure $modifyOptionsQueryUsing = null): static + public function relationship(string | Closure | null $name, string | Closure | null $titleAttribute, ?Closure $modifyQueryUsing = null): static { - $this->relationship = $relationshipName ?? $this->getName(); + $this->relationship = $name ?? $this->getName(); $this->relationshipTitleAttribute = $titleAttribute; - $this->getSearchResultsUsing(static function (Select $component, ?string $search) use ($modifyOptionsQueryUsing): array { + $this->getSearchResultsUsing(static function (Select $component, ?string $search) use ($modifyQueryUsing): array { $relationship = $component->getRelationship(); $relationshipQuery = $relationship->getRelated()->query(); - if ($modifyOptionsQueryUsing) { - $relationshipQuery = $component->evaluate($modifyOptionsQueryUsing, [ + if ($modifyQueryUsing) { + $relationshipQuery = $component->evaluate($modifyQueryUsing, [ 'query' => $relationshipQuery, ]) ?? $relationshipQuery; } @@ -683,7 +683,7 @@ class Select extends Field implements Contracts\HasAffixActions, Contracts\HasNe ->toArray(); }); - $this->options(static function (Select $component) use ($modifyOptionsQueryUsing): ?array { + $this->options(static function (Select $component) use ($modifyQueryUsing): ?array { if (($component->isSearchable()) && ! $component->isPreloaded()) { return null; } @@ -692,8 +692,8 @@ class Select extends Field implements Contracts\HasAffixActions, Contracts\HasNe $relationshipQuery = $relationship->getRelated()->query(); - if ($modifyOptionsQueryUsing) { - $relationshipQuery = $component->evaluate($modifyOptionsQueryUsing, [ + if ($modifyQueryUsing) { + $relationshipQuery = $component->evaluate($modifyQueryUsing, [ 'query' => $relationshipQuery, ]) ?? $relationshipQuery; } @@ -783,13 +783,13 @@ class Select extends Field implements Contracts\HasAffixActions, Contracts\HasNe return $record->getAttributeValue($component->getRelationshipTitleAttribute()); }); - $this->getSelectedRecordUsing(static function (Select $component, $state) use ($modifyOptionsQueryUsing): ?Model { + $this->getSelectedRecordUsing(static function (Select $component, $state) use ($modifyQueryUsing): ?Model { $relationship = $component->getRelationship(); $relationshipQuery = $relationship->getRelated()->query()->where($relationship->getOwnerKeyName(), $state); - if ($modifyOptionsQueryUsing) { - $relationshipQuery = $component->evaluate($modifyOptionsQueryUsing, [ + if ($modifyQueryUsing) { + $relationshipQuery = $component->evaluate($modifyQueryUsing, [ 'query' => $relationshipQuery, ]) ?? $relationshipQuery; } @@ -797,15 +797,15 @@ class Select extends Field implements Contracts\HasAffixActions, Contracts\HasNe return $relationshipQuery->first(); }); - $this->getOptionLabelsUsing(static function (Select $component, array $values) use ($modifyOptionsQueryUsing): array { + $this->getOptionLabelsUsing(static function (Select $component, array $values) use ($modifyQueryUsing): array { $relationship = $component->getRelationship(); $relatedKeyName = $relationship->getRelatedKeyName(); $relationshipQuery = $relationship->getRelated()->query() ->whereIn($relatedKeyName, $values); - if ($modifyOptionsQueryUsing) { - $relationshipQuery = $component->evaluate($modifyOptionsQueryUsing, [ + if ($modifyQueryUsing) { + $relationshipQuery = $component->evaluate($modifyQueryUsing, [ 'query' => $relationshipQuery, ]) ?? $relationshipQuery; } diff --git a/packages/forms/src/Concerns/HasComponents.php b/packages/forms/src/Concerns/HasComponents.php index dcde7eec2b..2c2c435aaa 100644 --- a/packages/forms/src/Concerns/HasComponents.php +++ b/packages/forms/src/Concerns/HasComponents.php @@ -33,21 +33,21 @@ trait HasComponents return $this; } - public function getComponent(string | Closure $callback, bool $withHidden = false): ?Component + public function getComponent(string | Closure $findComponentUsing, bool $withHidden = false): ?Component { - if (is_string($callback)) { - $callback = static function (Component $component) use ($callback): bool { + if (is_string($findComponentUsing)) { + $findComponentUsing = static function (Component $component) use ($findComponentUsing): bool { $key = $component->getKey(); if ($key === null) { return false; } - return $key === $callback; + return $key === $findComponentUsing; }; } - return collect($this->getFlatComponents($withHidden))->first($callback); + return collect($this->getFlatComponents($withHidden))->first($findComponentUsing); } /** diff --git a/packages/forms/src/Testing/TestsForms.php b/packages/forms/src/Testing/TestsForms.php index 82b3db3e01..6876a03b9c 100644 --- a/packages/forms/src/Testing/TestsForms.php +++ b/packages/forms/src/Testing/TestsForms.php @@ -138,9 +138,9 @@ class TestsForms public function assertFormFieldExists(): Closure { - return function (string $fieldName, string | Closure $formName = 'form', ?Closure $callback = null): static { + return function (string $fieldName, string | Closure $formName = 'form', ?Closure $checkFieldUsing = null): static { if ($formName instanceof Closure) { - $callback = $formName; + $checkFieldUsing = $formName; $formName = 'form'; } @@ -161,9 +161,9 @@ class TestsForms "Failed asserting that a field with the name [{$fieldName}] exists on the form with the name [{$formName}] on the [{$livewireClass}] component." ); - if ($callback) { + if ($checkFieldUsing) { Assert::assertTrue( - $callback($field), + $checkFieldUsing($field), "Failed asserting that a field with the name [{$fieldName}] and provided configuration exists on the form with the name [{$formName}] on the [{$livewireClass}] component." ); } diff --git a/packages/infolists/src/Components/Concerns/EntanglesStateWithSingularRelationship.php b/packages/infolists/src/Components/Concerns/EntanglesStateWithSingularRelationship.php index dd45f9f853..5366b4cf42 100644 --- a/packages/infolists/src/Components/Concerns/EntanglesStateWithSingularRelationship.php +++ b/packages/infolists/src/Components/Concerns/EntanglesStateWithSingularRelationship.php @@ -4,9 +4,9 @@ namespace Filament\Infolists\Components\Concerns; trait EntanglesStateWithSingularRelationship { - public function relationship(string $relationshipName): static + public function relationship(string $name): static { - $this->statePath($relationshipName); + $this->statePath($name); return $this; } diff --git a/packages/panels/src/FilamentManager.php b/packages/panels/src/FilamentManager.php index d5ffb2fa84..175797b153 100644 --- a/packages/panels/src/FilamentManager.php +++ b/packages/panels/src/FilamentManager.php @@ -612,10 +612,10 @@ class FilamentManager } } - public function registerRenderHook(string $name, Closure $callback): void + public function registerRenderHook(string $name, Closure $hook): void { try { - $this->getDefaultPanel()->renderHook($name, $callback); + $this->getDefaultPanel()->renderHook($name, $hook); } catch (NoDefaultPanelSetException $exception) { throw new Exception('Please use the `renderHook()` method on the panel configuration to register render hooks. See the documentation - https://filamentphp.com/docs/panels/configuration#render-hooks'); } diff --git a/packages/panels/src/Panel/Concerns/HasRenderHooks.php b/packages/panels/src/Panel/Concerns/HasRenderHooks.php index 6657bcca80..2211c74f77 100644 --- a/packages/panels/src/Panel/Concerns/HasRenderHooks.php +++ b/packages/panels/src/Panel/Concerns/HasRenderHooks.php @@ -13,9 +13,9 @@ trait HasRenderHooks */ protected array $renderHooks = []; - public function renderHook(string $name, Closure $callback): static + public function renderHook(string $name, Closure $hook): static { - $this->renderHooks[$name][] = $callback; + $this->renderHooks[$name][] = $hook; return $this; } diff --git a/packages/support/src/Commands/Concerns/CanValidateInput.php b/packages/support/src/Commands/Concerns/CanValidateInput.php index ac07086faa..0decfb8614 100644 --- a/packages/support/src/Commands/Concerns/CanValidateInput.php +++ b/packages/support/src/Commands/Concerns/CanValidateInput.php @@ -15,9 +15,9 @@ trait CanValidateInput /** * @param array $rules */ - protected function validateInput(Closure $callback, string $field, array $rules, ?Closure $onError = null): string + protected function validateInput(Closure $askUsing, string $field, array $rules, ?Closure $onError = null): string { - $input = $callback(); + $input = $askUsing(); $validator = Validator::make( [$field => $input], @@ -31,7 +31,7 @@ trait CanValidateInput $onError($validator); } - $input = $this->validateInput($callback, $field, $rules); + $input = $this->validateInput($askUsing, $field, $rules); } return $input; diff --git a/packages/support/src/Concerns/Configurable.php b/packages/support/src/Concerns/Configurable.php index d74f0191f0..0979b0fb94 100644 --- a/packages/support/src/Concerns/Configurable.php +++ b/packages/support/src/Concerns/Configurable.php @@ -16,14 +16,14 @@ trait Configurable */ protected static array $importantConfigurations = []; - public static function configureUsing(Closure $callback, ?Closure $during = null, bool $isImportant = false): mixed + public static function configureUsing(Closure $modifyUsing, ?Closure $during = null, bool $isImportant = false): mixed { if ($isImportant) { static::$importantConfigurations[static::class] ??= []; - static::$importantConfigurations[static::class][] = $callback; + static::$importantConfigurations[static::class][] = $modifyUsing; } else { static::$configurations[static::class] ??= []; - static::$configurations[static::class][] = $callback; + static::$configurations[static::class][] = $modifyUsing; } if (! $during) { diff --git a/packages/tables/src/Filters/Concerns/HasRelationship.php b/packages/tables/src/Filters/Concerns/HasRelationship.php index ab7a64c2a6..4a34496510 100644 --- a/packages/tables/src/Filters/Concerns/HasRelationship.php +++ b/packages/tables/src/Filters/Concerns/HasRelationship.php @@ -10,11 +10,11 @@ trait HasRelationship { protected ?Closure $modifyRelationshipQueryUsing = null; - public function relationship(string $relationshipName, string $titleAttribute = null, Closure $callback = null): static + public function relationship(string $name, string $titleAttribute = null, ?Closure $modifyQueryUsing = null): static { - $this->attribute("{$relationshipName}.{$titleAttribute}"); + $this->attribute("{$name}.{$titleAttribute}"); - $this->modifyRelationshipQueryUsing = $callback; + $this->modifyRelationshipQueryUsing = $modifyQueryUsing; return $this; }