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

Commit b4c9167

Browse files
Merge pull request #2 from TheDragonCode/dev
Big changes
2 parents 2adec24 + e516192 commit b4c9167

31 files changed

+1138
-450
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ yarn-error.log
2727
/.zed
2828
/.junie
2929
/.ai
30+
/.output.txt

app/Casts/FilamentTypeTitleCast.php

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

app/Concerns/WithColor.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Concerns;
6+
7+
use App\Models\Color;
8+
9+
trait WithColor
10+
{
11+
protected array $colors = [];
12+
13+
protected array $colorMap = [
14+
'Yellow' => '#FFFF00',
15+
'Green' => '#00FF00',
16+
'Blue' => '#0000FF',
17+
'Grey' => '#808080',
18+
'White' => '#FFFFFF',
19+
'Gold' => '#FFCF40',
20+
];
21+
22+
protected function color(string $name): Color
23+
{
24+
return $this->colors[$name] ??= Color::firstOrCreate([
25+
'title' => $name,
26+
'hex' => $this->colorMap[$name] ?? '#000000',
27+
]);
28+
}
29+
}

app/Concerns/WithFilaments.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Concerns;
6+
7+
use App\Models\Filament;
8+
use App\Models\FilamentType;
9+
use App\Models\Vendor;
10+
11+
trait WithFilaments
12+
{
13+
protected array $filamentTypes = [];
14+
15+
protected array $filaments = [];
16+
17+
protected function filamentType(string $value): FilamentType
18+
{
19+
return $this->filamentTypes[$value] ??= FilamentType::firstOrCreate(['title' => $value]);
20+
}
21+
22+
protected function filament(Vendor $vendor, FilamentType $filamentType): Filament
23+
{
24+
$key = $vendor->id . '-' . $filamentType->id;
25+
26+
return $this->filaments[$key] ??= $vendor->filaments()->updateOrCreate([
27+
'filament_type_id' => $filamentType->id,
28+
]);
29+
}
30+
}

app/Concerns/WithNozzles.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Concerns;
6+
7+
use App\Models\Nozzle;
8+
9+
trait WithNozzles
10+
{
11+
protected array $nozzles = [];
12+
13+
protected function nozzle(string|float $value): Nozzle
14+
{
15+
return $this->nozzles[(string) $value] ??= Nozzle::firstOrCreate(['title' => $value]);
16+
}
17+
}

app/Concerns/WithVendor.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Concerns;
6+
7+
use App\Models\Vendor;
8+
9+
trait WithVendor
10+
{
11+
protected array $vendors = [];
12+
13+
protected function vendor(string $name): Vendor
14+
{
15+
return $this->vendors[$name] ??= Vendor::firstOrCreate(['title' => $name]);
16+
}
17+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Console\Commands\OrcaSlicer;
6+
7+
use App\Services\OrcaSlicer\DownloadService;
8+
use App\Services\OrcaSlicer\FilamentTypeService;
9+
use App\Services\OrcaSlicer\MachineService;
10+
use App\Services\OrcaSlicer\MapService;
11+
use App\Services\OrcaSlicer\NozzleService;
12+
use Illuminate\Console\Command;
13+
14+
class ImportCommand extends Command
15+
{
16+
protected $signature = 'orca-slicer:import';
17+
18+
protected $description = 'Update resources from OrcaSlicer';
19+
20+
public function handle(
21+
DownloadService $download,
22+
MapService $map,
23+
MachineService $machine,
24+
NozzleService $nozzle,
25+
FilamentTypeService $filament,
26+
): void {
27+
//$this->components->task('Clean up', fn () => $download->cleanup());
28+
//$this->components->task('Download', fn () => $download->download());
29+
//$this->components->task('Extract', fn () => $download->extract());
30+
//$this->components->task('Release', fn () => $download->release());
31+
$this->components->task('Import map', fn () => $map->import());
32+
$this->components->task('Import machines', fn () => $machine->import());
33+
$this->components->task('Import nozzles', fn () => $nozzle->import());
34+
$this->components->task('Import filaments', fn () => $filament->import());
35+
}
36+
}

app/Console/Commands/OrcaSlicerCommand.php

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

app/Enums/SourceType.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Enums;
6+
7+
enum SourceType: string
8+
{
9+
case Machine = 'machine';
10+
case Filament = 'filament';
11+
case Process = 'process';
12+
}

app/Http/Controllers/HomeController.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@
44

55
namespace App\Http\Controllers;
66

7-
use App\Models\UserFilament;
7+
use App\Http\Requests\HomeFilterRequest;
8+
use App\Services\Pages\HomeService;
89
use Inertia\Inertia;
910

1011
class HomeController
1112
{
12-
public function __invoke()
13+
public function __invoke(HomeFilterRequest $request, HomeService $home)
1314
{
14-
$settings = UserFilament::query()
15-
->with([
16-
'machine.vendor',
17-
'filament' => ['vendor', 'type'],
18-
'color',
19-
])
20-
->orderBy('machine_id')
21-
->orderBy('filament_id')
22-
->orderBy('color_id')
23-
->orderBy('id')
24-
->get();
25-
2615
return Inertia::render('welcome', [
27-
'settings' => $settings,
16+
'userFilaments' => $home->userFilaments(
17+
$request->integer('machine_id'),
18+
$request->integer('filament_type_id'),
19+
$request->integer('color_id'),
20+
),
21+
'machines' => $home->machines(),
22+
'filamentTypes' => $home->filamentTypes(),
23+
'colors' => $home->colors(),
24+
'filters' => $request->validated(),
2825
]);
2926
}
3027
}

0 commit comments

Comments
 (0)