Skip to content

Commit 13c64cc

Browse files
authored
Merge pull request #45 from lara-zeus/update-configration
update configuration
2 parents 53be2fc + 7fd4b7b commit 13c64cc

12 files changed

+2701
-2632
lines changed

.phpunit.cache/test-results

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"pest_2.36.0","defects":[],"times":{"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.005}}

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
],
2525
"require": {
2626
"php": "^8.1",
27+
"lara-zeus/filament-plugin-tools": "^1.0",
2728
"lara-zeus/core": "^3.1"
2829
},
2930
"require-dev": {

composer.lock

+2,679-2,536
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon.dist

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ parameters:
66
paths:
77
- src
88
- database
9-
- tests
109
checkOctaneCompatibility: true
1110
checkModelProperties: true
12-
checkMissingIterableValueType: false
13-
checkGenericClassInNonGenericObjectType: false
11+
12+
ignoreErrors:
13+
-
14+
identifier: missingType.iterableValue
15+
-
16+
identifier: missingType.generics

src/Concerns/InteractWithWidgets.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function renderWidget(array $data): string | View
2525

2626
if ($widgetClass instanceof Widget) {
2727
$view = app('dynamic-dashboardTheme') . '.widgets.filament';
28-
//return Blade::render('');
28+
// return Blade::render('');
2929
}
3030

3131
$data = array_merge($data, $this->viewData($data));

src/Configuration.php

+1-85
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,9 @@
66

77
trait Configuration
88
{
9-
/**
10-
* you can overwrite any model and use your own
11-
*/
12-
protected array $models = [];
13-
14-
/**
15-
* set the default upload options.
16-
*/
179
protected Closure | string $defaultLayout = 'new-page';
1810

19-
protected Closure | string $uploadDisk = 'public';
20-
21-
protected Closure | string $uploadDirectory = 'layouts';
22-
23-
protected Closure | string $navigationGroupLabel = 'Dynamic Dashboard';
24-
25-
protected Closure | bool $hideLayoutResource = false;
26-
27-
public function models(array $models): static
28-
{
29-
$this->models = $models;
30-
31-
return $this;
32-
}
33-
34-
public function getModels(): array
35-
{
36-
return $this->models;
37-
}
38-
39-
public static function getModel(string $model): string
40-
{
41-
return array_merge(
42-
config('zeus-dynamic-dashboard.models'),
43-
(new static)::get()->getModels()
44-
)[$model];
45-
}
46-
47-
public function defaultLayout(Closure | string $layout): static
11+
public function setDefaultLayout(Closure | string $layout): static
4812
{
4913
$this->defaultLayout = $layout;
5014

@@ -55,52 +19,4 @@ public function getDefaultLayout(): Closure | string
5519
{
5620
return $this->evaluate($this->defaultLayout);
5721
}
58-
59-
public function uploadDisk(Closure | string $disk): static
60-
{
61-
$this->uploadDisk = $disk;
62-
63-
return $this;
64-
}
65-
66-
public function getUploadDisk(): Closure | string
67-
{
68-
return $this->evaluate($this->uploadDisk);
69-
}
70-
71-
public function uploadDirectory(Closure | string $dir): static
72-
{
73-
$this->uploadDirectory = $dir;
74-
75-
return $this;
76-
}
77-
78-
public function getUploadDirectory(): Closure | string
79-
{
80-
return $this->evaluate($this->uploadDirectory);
81-
}
82-
83-
public function navigationGroupLabel(Closure | string $lable): static
84-
{
85-
$this->navigationGroupLabel = $lable;
86-
87-
return $this;
88-
}
89-
90-
public function getNavigationGroupLabel(): Closure | string
91-
{
92-
return $this->evaluate($this->navigationGroupLabel);
93-
}
94-
95-
public function hideLayoutResource(Closure | bool $condition = true): static
96-
{
97-
$this->hideLayoutResource = $condition;
98-
99-
return $this;
100-
}
101-
102-
public function isLayoutResourceHidden(): Closure | bool
103-
{
104-
return $this->evaluate($this->hideLayoutResource);
105-
}
10622
}

src/DynamicDashboardPlugin.php

+11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22

33
namespace LaraZeus\DynamicDashboard;
44

5+
use Closure;
56
use Filament\Contracts\Plugin;
67
use Filament\Panel;
78
use Filament\Support\Concerns\EvaluatesClosures;
89
use LaraZeus\DynamicDashboard\Filament\Resources\LayoutResource;
10+
use LaraZeus\FilamentPluginTools\Concerns\CanHideResources;
11+
use LaraZeus\FilamentPluginTools\Concerns\HasModels;
12+
use LaraZeus\FilamentPluginTools\Concerns\HasNavigationGroupLabel;
13+
use LaraZeus\FilamentPluginTools\Concerns\HasUploads;
914

1015
final class DynamicDashboardPlugin implements Plugin
1116
{
17+
use CanHideResources;
1218
use Configuration;
1319
use EvaluatesClosures;
20+
use HasModels;
21+
use HasNavigationGroupLabel;
22+
use HasUploads;
23+
24+
protected Closure | string $navigationGroupLabel = 'Dynamic Dashboard';
1425

1526
public function getId(): string
1627
{

src/Filament/Resources/LayoutResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LayoutResource extends Resource
2121

2222
public static function shouldRegisterNavigation(): bool
2323
{
24-
return ! DynamicDashboardPlugin::get()->isLayoutResourceHidden();
24+
return DynamicDashboardPlugin::get()->isResourceVisible(static::class);
2525
}
2626

2727
public static function getModel(): string

src/Widgets/Classes/FaqWidget.php

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function form(): Builder\Block
4545
public function viewData(array $data): array
4646
{
4747
return [
48-
// @phpstan-ignore-next-line
4948
'faqs' => ($data['faq_cat'] !== null) ? config('zeus-sky.models.Faq')::withAnyTags([$data['faq_cat']], 'faq')->get() : null,
5049
];
5150
}

src/Widgets/Classes/LibraryWidget.php

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function form(): Builder\Block
4545
public function viewData(array $data): array
4646
{
4747
return [
48-
// @phpstan-ignore-next-line
4948
'library' => ($data['library_slug'] !== null) ? config('zeus-sky.models.Library')::withAnyTags([$data['library_slug']], 'library')->get() : null,
5049
];
5150
}

src/Widgets/Classes/MenuWidget.php

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function form(): Builder\Block
4848
public function viewData(array $data): array
4949
{
5050
return [
51-
// @phpstan-ignore-next-line
5251
'menu' => ($data['menu_slug'] !== null) ? config('zeus-sky.models.Navigation')::fromHandle($data['menu_slug']) : null,
5352
];
5453
}

src/Widgets/Classes/PostsWidget.php

-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function form(): Builder\Block
4949
->default('desc'),
5050

5151
Select::make('category')
52-
// @phpstan-ignore-next-line
5352
->options(config('zeus-sky.models.Tag')::query()
5453
->withType('category')
5554
->pluck('name', 'id')),
@@ -64,11 +63,9 @@ public function form(): Builder\Block
6463

6564
public function viewData(array $data): array
6665
{
67-
// @phpstan-ignore-next-line
6866
$posts = config('zeus-sky.models.Post')::query();
6967

7068
if ($data['category'] !== null) {
71-
// @phpstan-ignore-next-line
7269
$category = config('zeus-sky.models.Tag')::where('type', 'category')->find($data['category']);
7370
if ($category !== null) {
7471
$posts = $category->postsPublished();

0 commit comments

Comments
 (0)