Skip to content

Commit fea1b70

Browse files
committed
Datatables : Refactor to Query Method
Datatables: Ability to Override Query for Search, Filter, Sort. Datatables: Removed Json Resource in favor of simple & plain response
1 parent 99d7f46 commit fea1b70

File tree

8 files changed

+234
-282
lines changed

8 files changed

+234
-282
lines changed

src/Commands/VanillaComponentsCommand.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Core/Concerns/EvaluatesClosures.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,30 @@
44

55
use Closure;
66

7-
// From Filament
87
trait EvaluatesClosures
98
{
9+
/**
10+
* The identifier used to inject the component into the evaluation closure.
11+
*
12+
* @var string
13+
*/
1014
protected string $evaluationIdentifier;
1115

16+
/**
17+
* The parameters that should be removed from the evaluation closure.
18+
*
19+
* @var array
20+
*/
1221
protected array $evaluationParametersToRemove = [];
1322

23+
/**
24+
* Stolen from Filament, evaluate the closure with given params, and exclude some.
25+
*
26+
* @param $value
27+
* @param array $parameters
28+
* @param array $exceptParameters
29+
* @return mixed
30+
*/
1431
protected function evaluate($value, array $parameters = [], array $exceptParameters = [])
1532
{
1633
$this->evaluationParametersToRemove = $exceptParameters;
@@ -29,11 +46,23 @@ protected function evaluate($value, array $parameters = [], array $exceptParamet
2946
return $value;
3047
}
3148

49+
/**
50+
* Get the default params that should be always injected
51+
*
52+
* @return array
53+
*/
3254
protected function getDefaultEvaluationParameters(): array
3355
{
3456
return [];
3557
}
3658

59+
/**
60+
* Resolve the given evaluation parameter.
61+
*
62+
* @param string $parameter
63+
* @param Closure $value
64+
* @return mixed|null
65+
*/
3766
protected function resolveEvaluationParameter(string $parameter, Closure $value)
3867
{
3968
if ($this->isEvaluationParameterRemoved($parameter)) {
@@ -43,6 +72,12 @@ protected function resolveEvaluationParameter(string $parameter, Closure $value)
4372
return $value();
4473
}
4574

75+
/**
76+
* Determine if the given evaluation parameter should be removed.
77+
*
78+
* @param string $parameter
79+
* @return bool
80+
*/
4681
protected function isEvaluationParameterRemoved(string $parameter): bool
4782
{
4883
return in_array($parameter, $this->evaluationParametersToRemove);

src/Core/Concerns/InteractsWithPagination.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/Core/Concerns/Makable.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
trait Makable
66
{
7+
/**
8+
* Quick static constructor.
9+
*
10+
* @param array $args
11+
* @return static
12+
*/
713
public static function make(array $args = []): static
814
{
915
return new static(...$args);

0 commit comments

Comments
 (0)