Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 13e009b

Browse files
Refactor FilamentProfileService: adjust storage attribute, remove unused directory config, optimize query with relation handling, and simplify profile path construction.
1 parent c4db825 commit 13e009b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/Services/OrcaSlicer/FilamentProfileService.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@
77
use App\Data\OrcaSlicer\FilamentData;
88
use App\Enums\SourceType;
99
use App\Models\Map;
10-
use Illuminate\Container\Attributes\Config;
1110
use Illuminate\Container\Attributes\Storage;
11+
use Illuminate\Database\Eloquent\Builder;
1212
use Illuminate\Filesystem\FilesystemAdapter;
1313
use Illuminate\Support\Str;
1414

1515
class FilamentProfileService
1616
{
1717
public function __construct(
18-
#[Storage('orca_slicer')]
18+
#[Storage('orca_resources')]
1919
protected FilesystemAdapter $storage,
20-
#[Config('orca_slicer.directory')]
21-
protected string $directory,
2220
) {}
2321

2422
public function get(FilamentData $filament): FilamentData
@@ -60,8 +58,12 @@ protected function findPath(string $profile, string $key): ?string
6058
{
6159
return Map::query()
6260
->where('type', SourceType::Filament)
63-
->where('profile', $profile)
6461
->where('key', $key)
62+
->where(fn (Builder $builder) => $builder
63+
->whereRelation('parent', 'profile', $profile)
64+
->orwhere('profile', $profile)
65+
)
66+
->orderByDesc('parent_id')
6567
->first()?->path;
6668
}
6769

@@ -73,7 +75,7 @@ protected function profile(string $key): string
7375
protected function read(string $filename): array
7476
{
7577
return $this->storage->json(
76-
$this->directory . '/resources/profiles/' . $filename
78+
'profiles/' . $filename
7779
);
7880
}
7981

0 commit comments

Comments
 (0)