Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Mar 14, 2024
1 parent cdc436f commit 4f6e9c5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 103 deletions.
19 changes: 3 additions & 16 deletions src/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Cone\Root\Database\Factories\NotificationFactory;
use Cone\Root\Interfaces\Models\Notification as Contract;
use Cone\Root\Support\Filters;
use Cone\Root\Traits\InteractsWithProxy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
Expand Down Expand Up @@ -69,11 +68,7 @@ protected function formattedCreatedAt(): Attribute
{
return new Attribute(
get: function (): ?string {
return Filters::apply(
'root:notification.formatted_created_at_attribute',
$this->created_at?->isoFormat('YYYY. MMMM DD. HH:mm'),
$this
);
return $this->created_at?->isoFormat('YYYY. MMMM DD. HH:mm');
}
);
}
Expand All @@ -87,11 +82,7 @@ protected function isRead(): Attribute
{
return new Attribute(
get: function (): bool {
return Filters::apply(
'root:notification.is_read_attribute',
! is_null($this->read_at),
$this
);
return ! is_null($this->read_at);
}
);
}
Expand All @@ -105,11 +96,7 @@ protected function url(): Attribute
{
return new Attribute(
get: function (): ?string {
return Filters::apply(
'root:notification.url_attribute',
$this->exists ? URL::route('root.api.notifications.update', $this) : null,
$this
);
return $this->exists ? URL::route('root.api.notifications.update', $this) : null;
}
);
}
Expand Down
66 changes: 0 additions & 66 deletions src/Support/Filters.php

This file was deleted.

7 changes: 2 additions & 5 deletions src/Traits/ResolvesActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Closure;
use Cone\Root\Actions\Action;
use Cone\Root\Actions\Actions;
use Cone\Root\Support\Filters;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;

Expand Down Expand Up @@ -45,16 +44,14 @@ public function withActions(Closure $callback): static
public function resolveActions(Request $request): Actions
{
if (is_null($this->actions)) {
$actions = new Actions($this->actions($request));
$this->actions = new Actions($this->actions($request));

$actions->when(! is_null($this->actionsResolver), function (Actions $actions) use ($request): void {
$this->actions->when(! is_null($this->actionsResolver), function (Actions $actions) use ($request): void {
$actions->register(
Arr::wrap(call_user_func_array($this->actionsResolver, [$request]))
);
});

$this->actions = Filters::apply(static::class.'.actions', $actions, $this);

$this->actions->each(function (Action $action) use ($request): void {
$this->resolveAction($request, $action);
});
Expand Down
7 changes: 2 additions & 5 deletions src/Traits/ResolvesFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cone\Root\Fields\Fields;
use Cone\Root\Fields\File;
use Cone\Root\Fields\Media;
use Cone\Root\Support\Filters;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;

Expand Down Expand Up @@ -61,16 +60,14 @@ public function hasFileField(Request $request): bool
public function resolveFields(Request $request): Fields
{
if (is_null($this->fields)) {
$fields = new Fields($this->fields($request));
$this->fields = new Fields($this->fields($request));

$fields->when(! is_null($this->fieldsResolver), function (Fields $fields) use ($request): void {
$this->fields->when(! is_null($this->fieldsResolver), function (Fields $fields) use ($request): void {
$fields->register(
Arr::wrap(call_user_func_array($this->fieldsResolver, [$request]))
);
});

$this->fields = Filters::apply(static::class.'.fields', $fields, $this);

$this->fields->each(function (Field $field) use ($request): void {
$this->resolveField($request, $field);
});
Expand Down
7 changes: 2 additions & 5 deletions src/Traits/ResolvesFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Closure;
use Cone\Root\Filters\Filter;
use Cone\Root\Filters\Filters;
use Cone\Root\Support\Filters as ValueFilters;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;

Expand Down Expand Up @@ -47,16 +46,14 @@ public function withFilters(Closure $callback): static
public function resolveFilters(Request $request): Filters
{
if (is_null($this->filters)) {
$filters = new Filters($this->filters($request));
$this->filters = new Filters($this->filters($request));

$filters->when(! is_null($this->filtersResolver), function (Filters $filters) use ($request): void {
$this->filters->when(! is_null($this->filtersResolver), function (Filters $filters) use ($request): void {
$filters->register(
Arr::wrap(call_user_func_array($this->filtersResolver, [$request]))
);
});

$this->filters = ValueFilters::apply(static::class.'.filters', $filters, $this);

$this->filters->each(function (Filter $filter) use ($request): void {
$this->resolveFilter($request, $filter);
});
Expand Down
5 changes: 1 addition & 4 deletions src/Traits/ResolvesWidgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Cone\Root\Traits;

use Cone\Root\Support\Filters;
use Cone\Root\Widgets\Widget;
use Cone\Root\Widgets\Widgets;
use Illuminate\Http\Request;
Expand All @@ -28,9 +27,7 @@ public function widgets(Request $request): array
public function resolveWidgets(Request $request): Widgets
{
if (is_null($this->widgets)) {
$widgets = new Widgets($this->widgets($request));

$this->widgets = Filters::apply(static::class.'.widgets', $widgets, $this);
$this->widgets = new Widgets($this->widgets($request));

$this->widgets->each(function (Widget $widget) use ($request): void {
$this->resolveWidget($request, $widget);
Expand Down
7 changes: 5 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Cone\Root\Tests;

use Cone\Root\Interfaces\Models\User as UserInterface;
use Cone\Root\Root;
use Cone\Root\Support\Filters;
use Cone\Root\Tests\Resources\UserResource;
use Illuminate\Contracts\Console\Kernel;
Expand All @@ -21,6 +22,10 @@ public function createApplication(): Application

$app->booting(static function () use ($app): void {
$app->bind(UserInterface::class, User::class);

Root::instance()->resources->register([
new UserResource(),
]);
});

$app->make(Kernel::class)->bootstrap();
Expand All @@ -32,8 +37,6 @@ public function setUp(): void
{
parent::setUp();

Filters::register('root:resources', fn (): array => [new UserResource()]);

$this->app['router']->getRoutes()->refreshNameLookups();

$this->startSession();
Expand Down

0 comments on commit 4f6e9c5

Please sign in to comment.