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

Commit f0d6d9a

Browse files
Remove unused FilamentCast and ProfileData classes; refactor FilamentData structure and FilamentService implementation for streamlined filament handling.
1 parent 0a6ed20 commit f0d6d9a

File tree

6 files changed

+24
-128
lines changed

6 files changed

+24
-128
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ yarn-error.log
2828
/.junie
2929
/.ai
3030
/.output.txt
31+
/routes/playground.php

app/Data/Casts/ArrayToIntegerCast.php

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

1212
class ArrayToIntegerCast implements Cast
1313
{
14-
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): mixed
14+
public function cast(DataProperty $property, mixed $value, array $properties, CreationContext $context): int
1515
{
1616
if (is_array($value)) {
1717
return (int) array_first($value);

app/Data/Casts/OrcaSlicer/FilamentCast.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

app/Data/OrcaSlicer/FilamentData.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
use App\Data\Casts\ArrayToFloatCast;
66
use App\Data\Casts\ArrayToIntegerCast;
7-
use App\Data\Casts\OrcaSlicer\FilamentMachineCast;
8-
use App\Data\Casts\OrcaSlicer\FilamentTitleCast;
9-
use Illuminate\Support\Str;
107
use Spatie\LaravelData\Attributes\MapInputName;
118
use Spatie\LaravelData\Attributes\MapName;
129
use Spatie\LaravelData\Attributes\MapOutputName;
@@ -18,16 +15,14 @@
1815
class FilamentData extends Data
1916
{
2017
public function __construct(
18+
#[MapInputName('filament_settings_id')]
2119
#[MapOutputName('external_id')]
22-
public string $settingId,
20+
public string $settingsId,
2321

24-
#[MapInputName('name')]
25-
#[WithCast(FilamentTitleCast::class)]
26-
public string $title,
22+
#[MapInputName('default_filament_colour')]
23+
public ?string $color = null,
2724

28-
#[MapInputName('name')]
29-
#[WithCast(FilamentMachineCast::class)]
30-
public string $machine,
25+
public ?string $inherits = null,
3126

3227
#[WithCast(ArrayToFloatCast::class)]
3328
public float $pressureAdvance = 0,
@@ -42,12 +37,4 @@ public function __construct(
4237
#[WithCast(ArrayToIntegerCast::class)]
4338
public int $nozzleTemperatureInitialLayer = 0,
4439
) {}
45-
46-
public static function prepareForPipeline(array $properties): array
47-
{
48-
$properties['filament_id'] ??= Str::slug($properties['name']);
49-
$properties['setting_id'] ??= $properties['filament_id'];
50-
51-
return $properties;
52-
}
5340
}

app/Data/OrcaSlicer/ProfileData.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

app/Services/OrcaSlicer/FilamentService.php

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,42 @@
55
namespace App\Services\OrcaSlicer;
66

77
use App\Data\OrcaSlicer\FilamentData;
8-
use App\Exceptions\FilamentProfileNotFoundException;
8+
use App\Enums\SourceType;
9+
use App\Models\Map;
910
use Illuminate\Container\Attributes\Config;
1011
use Illuminate\Container\Attributes\Storage;
1112
use Illuminate\Filesystem\FilesystemAdapter;
12-
13-
use function array_merge;
14-
use function file_exists;
15-
use function file_get_contents;
16-
use function implode;
17-
use function json_decode;
18-
use function report;
13+
use Illuminate\Support\Str;
1914

2015
class FilamentService
2116
{
2217
public function __construct(
2318
#[Storage('orca_slicer')]
2419
protected FilesystemAdapter $storage,
2520
#[Config('orca_slicer.directory')]
26-
protected string $directory
21+
protected string $directory,
2722
) {}
2823

29-
public function get(string $vendor, string $profile, array $meta): ?FilamentData
30-
{
31-
if (! $parameters = $this->parameters($vendor, $profile)) {
32-
return null;
33-
}
34-
35-
$parameters['machine'] = $profile;
36-
$parameters['meta'] = $meta;
24+
public function get(FilamentData $filament): FilamentData {}
3725

38-
return FilamentData::from($parameters);
39-
}
40-
41-
protected function parameters(string $vendor, string $profile): array
26+
protected function findPath(string $profile, string $key): ?string
4227
{
43-
$parameters = $this->load($vendor, $profile);
44-
45-
if (! $parent = $parameters['inherits'] ?? false) {
46-
return $parameters;
47-
}
48-
49-
$previous = $this->parameters($vendor, $parent);
50-
51-
return array_merge($previous, $parameters);
28+
return Map::query()
29+
->where('type', SourceType::Filament)
30+
->where('profile', $profile)
31+
->where('key', $key)
32+
->first()?->path;
5233
}
5334

54-
protected function load(string $vendor, string $profile): array
35+
protected function profile(string $key): string
5536
{
56-
$path = $this->path($vendor, $profile);
57-
58-
if (! file_exists($path)) {
59-
report(new FilamentProfileNotFoundException($vendor, $profile, $path));
60-
61-
return [];
62-
}
63-
64-
return json_decode(file_get_contents($this->path($vendor, $profile)), true);
37+
return Str::before($key, ' ');
6538
}
6639

67-
protected function path(string $vendor, string $profile): string
40+
protected function read(string $filename): array
6841
{
69-
return $this->storage->path(implode(DIRECTORY_SEPARATOR, [
70-
$this->directory,
71-
'resources/profiles',
72-
$vendor,
73-
'filament',
74-
$profile . '.json',
75-
]));
42+
return $this->storage->json(
43+
$this->directory . '/resources/profiles/' . $filename
44+
);
7645
}
7746
}

0 commit comments

Comments
 (0)