Skip to content

Commit 5b5f590

Browse files
committed
feat(Filterable): add HandleFluentReturn trait and implement dynamic method handling
1 parent 4fe4dec commit 5b5f590

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

src/Filterable.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Kettasoft\Filterable\Foundation\Contracts\Sortable;
2323
use Kettasoft\Filterable\Foundation\FilterableSettings;
2424
use Kettasoft\Filterable\Exceptions\MissingBuilderException;
25+
use Kettasoft\Filterable\Foundation\Traits\HandleFluentReturn;
2526
use Kettasoft\Filterable\Engines\Foundation\Executors\Executer;
2627
use Kettasoft\Filterable\Foundation\Contracts\FilterableProfile;
2728
use Kettasoft\Filterable\Foundation\Contracts\Sorting\Invokable;
@@ -42,6 +43,7 @@ class Filterable implements FilterableContext, Authorizable, Validatable, Commit
4243
Traits\HasFilterableEvents,
4344
Traits\InteractsWithProvidedData,
4445
Traits\HasFilterableCache,
46+
HandleFluentReturn,
4547
Macroable;
4648

4749
/**
@@ -82,7 +84,7 @@ class Filterable implements FilterableContext, Authorizable, Validatable, Commit
8284

8385
/**
8486
* The Builder instance.
85-
* @var Builder
87+
* @var \Illuminate\Database\Eloquent\Builder
8688
*/
8789
protected Builder $builder;
8890

@@ -176,7 +178,7 @@ public function __construct(Request|null $request = null)
176178

177179
/**
178180
* Initialize core dependencies and fire the initializing event.
179-
*
181+
*
180182
* @return void
181183
*/
182184
public function boot($request = null)
@@ -190,7 +192,7 @@ public function boot($request = null)
190192

191193
/**
192194
* Prepare engine and internal components.
193-
*
195+
*
194196
* @return void
195197
*/
196198
public function booting()
@@ -203,7 +205,7 @@ public function booting()
203205

204206
/**
205207
* Finalize setup and fire the booted event.
206-
*
208+
*
207209
* @return void
208210
*/
209211
public function booted()
@@ -217,7 +219,7 @@ public function booted()
217219

218220
/**
219221
* Get request source.
220-
*
222+
*
221223
* @return string
222224
*/
223225
public function getRequestSource(): string
@@ -227,7 +229,7 @@ public function getRequestSource(): string
227229

228230
/**
229231
* Apply a filterable profile to the current instance.
230-
*
232+
*
231233
* @param FilterableProfile|string $profile
232234
* @return static
233235
*/
@@ -268,7 +270,7 @@ public function useProfile(FilterableProfile|callable|string $profile): static
268270

269271
/**
270272
* Commit clause.
271-
*
273+
*
272274
* @param string $key
273275
* @param Clause $clause
274276
* @return bool
@@ -281,7 +283,7 @@ public function commit(string $key, Clause $clause): bool
281283

282284
/**
283285
* Get applied clauses.
284-
*
286+
*
285287
* @param string $key
286288
* @return array|Clause|null
287289
*/
@@ -430,7 +432,7 @@ public static function tap(callable $callback, $instance = null): static
430432

431433
/**
432434
* Add a sorting callback for a specific filterable.
433-
*
435+
*
434436
* @param string|array $filterable
435437
* @param callable $callback
436438
* @return void
@@ -459,7 +461,7 @@ public static function addSorting(string|array $filterable, callable|string|Invo
459461

460462
/**
461463
* Define sorting rules for the current filterable instance.
462-
*
464+
*
463465
* @param callable $sorting
464466
* @return static
465467
*/
@@ -899,7 +901,7 @@ public function setFieldsMap($fields, bool $override = true): static
899901
}
900902

901903
/**
902-
* Get registered filter builder.
904+
* Get registered filter builder.
903905
* @return Builder
904906
*/
905907
public function getBuilder(): Builder
@@ -960,7 +962,7 @@ public function get(string $key)
960962

961963
/**
962964
* Get exception handler instance.
963-
*
965+
*
964966
* @return ExceptionHandlerInterface
965967
*/
966968
public function getExceptionHandler(): ExceptionHandlerInterface
@@ -986,4 +988,15 @@ public function __get($property): mixed
986988

987989
return $this->get($property);
988990
}
991+
992+
/**
993+
* Handle dynamic method calls to the builder.
994+
* @param string $method
995+
* @param array $parameters
996+
* @return mixed
997+
*/
998+
public function __call($method, $parameters)
999+
{
1000+
return $this->handleFluentReturn($method, $parameters);
1001+
}
9891002
}

0 commit comments

Comments
 (0)