Skip to content

Commit 8d3f29b

Browse files
committed
WIP
1 parent f874360 commit 8d3f29b

28 files changed

+165
-178
lines changed

resources/views/footer.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<p class="small mb-0">
3030
{{ __('The application code is published under the MIT license.') }} 2016 - {{date('Y')}}<br>
3131
<a href="http://orchid.software" target="_blank" rel="noopener">
32-
{{ __('Version') }}: {{\Orchid\Platform\Dashboard::version()}}
32+
{{ __('Version') }}: {{ Dashboard::version() }}
3333
</a>
3434
</p>
3535
</div>

resources/views/partials/update-assets.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@if(!\Orchid\Platform\Dashboard::assetsAreCurrent())
1+
@if(!Dashboard::assetsAreCurrent())
22
<div class="alert alert-warning rounded shadow-sm mb-3 p-4" data-turbo-temporary>
33
<div class="d-flex align-items-center mb-2 text-body-emphasis">
44
<x-orchid-icon path="bs.exclamation-triangle" width="2em" height="2em" class="me-2"/>

src/Access/RoleAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Database\Eloquent\Collection;
99
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
1010
use Illuminate\Database\Eloquent\SoftDeletes;
11-
use Orchid\Platform\Dashboard;
11+
use Orchid\Support\Facades\Dashboard;
1212
use Orchid\Platform\Models\User;
1313

1414
trait RoleAccess

src/Access/UserAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Illuminate\Database\Eloquent\SoftDeletes;
1313
use Illuminate\Support\Arr;
1414
use Illuminate\Support\Str;
15-
use Orchid\Platform\Dashboard;
15+
use Orchid\Support\Facades\Dashboard;
1616
use Orchid\Platform\Events\AddRoleEvent;
1717
use Orchid\Platform\Events\RemoveRoleEvent;
1818
use Orchid\Platform\Models\Role;

src/Attachment/Attachable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Illuminate\Database\Eloquent\Relations\MorphToMany;
88
use Orchid\Attachment\Models\Attachment;
9-
use Orchid\Platform\Dashboard;
9+
use Orchid\Support\Facades\Dashboard;
1010

1111
/**
1212
* This trait is used to relate or attach multiple files with Eloquent models.

src/Attachment/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Orchid\Attachment\Contracts\Engine;
1414
use Orchid\Attachment\Engines\Generator;
1515
use Orchid\Attachment\Models\Attachment;
16-
use Orchid\Platform\Dashboard;
16+
use Orchid\Support\Facades\Dashboard;
1717
use Orchid\Platform\Events\ReplicateFileEvent;
1818
use Orchid\Platform\Events\UploadFileEvent;
1919

src/Attachment/Models/Attachment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Orchid\Filters\Filterable;
1616
use Orchid\Filters\Types\Like;
1717
use Orchid\Platform\Concerns\Sortable;
18-
use Orchid\Platform\Dashboard;
18+
use Orchid\Support\Facades\Dashboard;
1919
use Orchid\Platform\Models\User;
2020
use Orchid\Screen\AsSource;
2121

src/Platform/Commands/InstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Console\Command;
88
use Illuminate\Support\Facades\App;
99
use Illuminate\Support\Traits\Conditionable;
10-
use Orchid\Platform\Dashboard;
10+
use Orchid\Support\Facades\Dashboard;
1111
use Orchid\Platform\Events\InstallEvent;
1212
use Orchid\Platform\Providers\ConsoleServiceProvider;
1313
use Symfony\Component\Console\Attribute\AsCommand;

src/Platform/Configuration/ManagesMenu.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,18 @@
22

33
namespace Orchid\Platform\Configuration;
44

5-
use Illuminate\Support\Collection;
65
use Orchid\Screen\Actions\Menu;
6+
use Orchid\Support\Attributes\ClearsOctaneState;
77

88
trait ManagesMenu
99
{
1010
/**
1111
* The collection of menu items.
1212
*
13-
* @var Collection<Menu>
13+
* @var array<Menu>
1414
*/
15-
private ?Collection $menuItems;
16-
17-
/**
18-
* @return Collection<Menu>
19-
*/
20-
public function menu(): Collection
21-
{
22-
$this->menuItems = $this->menuItems ?? collect();
23-
24-
return $this->menuItems;
25-
}
15+
#[ClearsOctaneState]
16+
protected array $menuItems = [];
2617

2718
/**
2819
* Register a menu element with the Dashboard.
@@ -34,10 +25,10 @@ public function menu(): Collection
3425
public function registerMenuElement(Menu $menu): static
3526
{
3627
if ($menu->get('sort', 0) === 0) {
37-
$menu->sort($this->menu->count() + 1);
28+
$menu->sort(count($this->menuItems) + 1);
3829
}
3930

40-
$this->menu()->add($menu);
31+
$this->menuItems[] = $menu;
4132

4233
return $this;
4334
}
@@ -51,7 +42,7 @@ public function registerMenuElement(Menu $menu): static
5142
*/
5243
public function renderMenu(): string
5344
{
54-
return $this->menu()
45+
return collect($this->menuItems)
5546
->sort(fn (Menu $current, Menu $next) => $current->get('sort', 0) <=> $next->get('sort', 0))
5647
->map(fn (Menu $menu) => (string) $menu->render())
5748
->implode('');
@@ -64,7 +55,7 @@ public function renderMenu(): string
6455
*/
6556
public function isEmptyMenu(): bool
6657
{
67-
return $this->menu()->isEmpty();
58+
return empty($this->menuItems);
6859
}
6960

7061
/**
@@ -77,10 +68,11 @@ public function isEmptyMenu(): bool
7768
*/
7869
public function addMenuSubElements(string $slug, array $list): static
7970
{
80-
$this->menuItems = $this->menu()
71+
$this->menuItems = collect($this->menuItems)
8172
->map(fn (Menu $menu) => $slug === $menu->get('slug')
8273
? $menu->list($list)
83-
: $menu);
74+
: $menu)
75+
->all();
8476

8577
return $this;
8678
}

src/Platform/Configuration/ManagesModelOptions.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,38 @@
66

77
trait ManagesModelOptions
88
{
9+
protected array $registeredReplaceModels = [];
10+
911
/**
1012
* Get the model instance for a given key or class name.
1113
*
14+
* @param string $key
15+
* @param string|null $default
16+
*
1217
* @return mixed
1318
*/
14-
public static function modelClass(string $key, ?string $default = null)
19+
public function modelClass(string $key, ?string $default = null): mixed
1520
{
16-
$model = static::model($key, $default);
21+
$model = $this->model($key, $default);
1722

1823
return class_exists($model) ? new $model : $model;
1924
}
2025

2126
/**
2227
* Get the class name for a given Dashboard model.
2328
*/
24-
public static function model(string $key, ?string $default = null): string
29+
public function model(string $key, ?string $default = null): string
2530
{
26-
return Arr::get(static::$options, 'models.'.$key, $default ?? $key);
31+
return Arr::get($this->registeredReplaceModels, $key, $default ?? $key);
2732
}
2833

2934
/**
3035
* Get the user model class name.
3136
*/
32-
public static function useModel(string $key, string $custom): void
37+
public function useModel(string $key, string $custom): static
3338
{
34-
static::$options['models'][$key] = $custom;
39+
$this->registeredReplaceModels[$key] = $custom;
40+
41+
return $this;
3542
}
3643
}

0 commit comments

Comments
 (0)