Skip to content

Commit 8c75c9b

Browse files
authored
Merge pull request #353 from lara-zeus/refacto-configration
refactor configration
2 parents c58c325 + 932f415 commit 8c75c9b

File tree

2 files changed

+9
-58
lines changed

2 files changed

+9
-58
lines changed

src/BoltPlugin.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LaraZeus\Bolt;
44

5+
use Closure;
56
use Filament\Contracts\Plugin;
67
use Filament\Panel;
78
use Filament\Support\Concerns\EvaluatesClosures;
@@ -10,16 +11,24 @@
1011
use LaraZeus\Bolt\Filament\Resources\FormResource;
1112
use LaraZeus\FilamentPluginTools\Concerns\CanDisableBadges;
1213
use LaraZeus\FilamentPluginTools\Concerns\CanGloballySearch;
14+
use LaraZeus\FilamentPluginTools\Concerns\CanHideResources;
15+
use LaraZeus\FilamentPluginTools\Concerns\HasModels;
16+
use LaraZeus\FilamentPluginTools\Concerns\HasNavigationGroupLabel;
1317
use LaraZeus\FilamentPluginTools\Concerns\HasRouteNamePrefix;
1418

1519
final class BoltPlugin implements Plugin
1620
{
1721
use CanDisableBadges;
1822
use CanGloballySearch;
23+
use CanHideResources;
1924
use Configuration;
2025
use EvaluatesClosures;
26+
use HasModels;
27+
use HasNavigationGroupLabel;
2128
use HasRouteNamePrefix;
2229

30+
protected Closure | string $navigationGroupLabel = 'Bolt';
31+
2332
public array $defaultGloballySearchableAttributes = [
2433
CategoryResource::class => ['name', 'slug'],
2534
CollectionResource::class => ['name', 'values'],

src/Configuration.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,19 @@
22

33
namespace LaraZeus\Bolt;
44

5-
use Closure;
6-
75
trait Configuration
86
{
9-
/**
10-
* you can overwrite any model and use your own
11-
*/
12-
protected array $boltModels = [];
13-
147
protected array $customSchema = [
158
'form' => null,
169
'section' => null,
1710
'field' => null,
1811
];
1912

20-
protected array $hideResources = [];
21-
2213
/**
2314
* available extensions, leave it null to disable the extensions tab from the forms
2415
*/
2516
protected ?array $extensions = null;
2617

27-
/**
28-
* the resources navigation group
29-
*/
30-
protected Closure | string $navigationGroupLabel = 'Bolt';
31-
3218
protected bool $formActionsAreSticky = false;
3319

3420
public function customSchema(array $schema): static
@@ -48,38 +34,6 @@ public static function getSchema(string $type): ?string
4834
return (new static)::get()->getCustomSchema()[$type];
4935
}
5036

51-
public function boltModels(array $models): static
52-
{
53-
$this->boltModels = $models;
54-
55-
return $this;
56-
}
57-
58-
public function getBoltModels(): array
59-
{
60-
return $this->boltModels;
61-
}
62-
63-
public static function getModel(string $model): ?string
64-
{
65-
return array_merge(
66-
config('zeus-bolt.models'),
67-
(new static)::get()->getBoltModels()
68-
)[$model] ?? null;
69-
}
70-
71-
public function navigationGroupLabel(Closure | string $label): static
72-
{
73-
$this->navigationGroupLabel = $label;
74-
75-
return $this;
76-
}
77-
78-
public function getNavigationGroupLabel(): Closure | string
79-
{
80-
return $this->evaluate($this->navigationGroupLabel);
81-
}
82-
8337
public function formActionsAreSticky(bool $condition = false): static
8438
{
8539
$this->formActionsAreSticky = $condition;
@@ -103,16 +57,4 @@ public function getExtensions(): ?array
10357
{
10458
return $this->extensions;
10559
}
106-
107-
public function hideResources(array $resources): static
108-
{
109-
$this->hideResources = $resources;
110-
111-
return $this;
112-
}
113-
114-
public function getHiddenResources(): ?array
115-
{
116-
return $this->hideResources;
117-
}
11860
}

0 commit comments

Comments
 (0)