diff --git a/app/Livewire/Filament/Buildplate.php b/app/Livewire/Filament/Buildplate.php index ca261cf..9cbe5c4 100644 --- a/app/Livewire/Filament/Buildplate.php +++ b/app/Livewire/Filament/Buildplate.php @@ -2,7 +2,9 @@ namespace App\Livewire\Filament; +use App\Models\Manufacturer as Manufacturer; use Flux\Flux; +use Illuminate\Support\Facades\Auth; use Livewire\Attributes\Title; use Livewire\Attributes\Validate; use Livewire\Component; @@ -16,6 +18,10 @@ class Buildplate extends Component #[Validate('required')] public $name = ''; + public $description = ''; + public $manufacturer_id = ''; + public $temp_max = ''; + public $amount = ''; public $search =''; @@ -25,10 +31,82 @@ class Buildplate extends Component public $editid = ''; public $deleteid = ''; + + public function edit($buildplateid) { + @Auth::check(); + + $editid = $buildplateid; + $this->editid = $editid; + + $buildplate = BuildplateModel::findOrFail($editid); + + $this->name = $buildplate->name; + $this->description = $buildplate->description; + $this->manufacturer_id = $buildplate->manufacturer_id; + $this->temp_max = $buildplate->temp_max; + $this->amount = $buildplate->amount; + + Flux::modal('editModal')->show(); + } + + public function save($editid) { + @Auth::check(); + + $buildplate = BuildplateModel::findOrFail($editid); + $buildplate->name = $this->name; + $buildplate->description = $this->description; + $buildplate->manufactuerer_id = $this->manufacturer_id; + $buildplate->temp_max = $this->temp_max; + $buildplate->amount = $this->amount; + $buildplate->save(); + + $this->resetInputFields(); + + Flux::modal('editModal')->close(); + } + + public function deleteModal($buildplateid) { + @Auth::check(); + + $deleteid = $buildplateid; + $this->deleteid = $deleteid; + + $buildplate = BuildplateModel::findOrFail($deleteid); + $this->name = $buildplate->name; + $this->description = $buildplate->description; + $this->manufacturer_id = $buildplate->manufacturer_id; + $this->temp_max = $buildplate->temp_max; + $this->amount = $buildplate->amount; + + Flux::modal('deleteModal')->show(); + } + + public function delete($deleteid) { + @Auth::check(); + + $buildplate = BuildplateModel::findOrFail($deleteid)->delete(); + + $this->deleteid = $deleteid; + Flux::modal('deleteModal')->close(); + + // Clear the form + $this->resetInputFields(); + } + + public function cancel() { + $this->resetInputFields(); + Flux::modals()->close(); + } + + public function resetInputFields() { + $this->reset(['name', 'description', 'manufacturer_id', 'temp_max', 'amount', 'deleteid', 'editid']);; + } + public function render() { return view('livewire.filament.buildplate', [ - 'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20) + 'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20), + 'manufacturers' => Manufacturer::all(), ]); } } diff --git a/app/Livewire/Filament/Type.php b/app/Livewire/Filament/Type.php index e23e471..7b6c542 100644 --- a/app/Livewire/Filament/Type.php +++ b/app/Livewire/Filament/Type.php @@ -25,14 +25,16 @@ class Type extends Component public $editid = ''; public $deleteid = ''; - + + public $amount = '0'; + public function create() { @Auth::check(); // Validate - $this->validate(); + $this->validate(); $type = new FilamentType(); $type->name = $this->name; @@ -56,20 +58,20 @@ class Type extends Component $this->name = $type->name; $this->description = $type->description; - + Flux::modal('editModal')->show(); } public function save($editid) { @Auth::check(); - + $type = FilamentType::findOrFail($editid); $type->name = $this->name; $type->description = $this->description; $type->save(); $this->resetInputFields(); - + Flux::modal('editModal')->close(); } public function deleteModal($typeid) { @@ -108,6 +110,7 @@ class Type extends Component { return view('livewire.filament.type', [ 'types' => FilamentType::search('name', $this->search)->paginate(10) + ]); } } diff --git a/app/Models/Buildplate.php b/app/Models/Buildplate.php index 132fa9f..46d5b4f 100644 --- a/app/Models/Buildplate.php +++ b/app/Models/Buildplate.php @@ -13,7 +13,8 @@ class Buildplate extends Model 'name', 'description', 'manufacturer_id', - 'temp_max' + 'temp_max', + 'amount' ]; public function filament() diff --git a/database/migrations/2025_03_15_185700_create_buildplates_table.php b/database/migrations/2025_03_15_185700_create_buildplates_table.php index 378c344..de35dbf 100644 --- a/database/migrations/2025_03_15_185700_create_buildplates_table.php +++ b/database/migrations/2025_03_15_185700_create_buildplates_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->string('description'); $table->foreignId('manufacturer_id')->constrained(); $table->string('temp_max'); + $table->string('amount'); $table->timestamps(); }); } diff --git a/database/seeders/BuildplateSeeder.php b/database/seeders/BuildplateSeeder.php index 96ef4c6..55b7686 100644 --- a/database/seeders/BuildplateSeeder.php +++ b/database/seeders/BuildplateSeeder.php @@ -15,8 +15,8 @@ class BuildplateSeeder extends Seeder { // Create Predefined Filament Types $buildplates = [ - ['name' => 'Supertrack', 'description' => 'Standard filament type.', 'manufacturer_id' => 1, 'temp_max' => 230], - ['name' => 'Smooth PEI', 'description' => 'Premium filament type.', 'manufacturer_id' => 1, 'temp_max' => 230], + ['name' => 'Supertrack', 'description' => 'Standard filament type.', 'manufacturer_id' => 1, 'temp_max' => 230, 'amount' => 1], + ['name' => 'Smooth PEI', 'description' => 'Premium filament type.', 'manufacturer_id' => 1, 'temp_max' => 230, 'amount' => 1], ]; foreach ($buildplates as $buildplate) { diff --git a/package-lock.json b/package-lock.json index 386b190..38c1f79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1966,6 +1966,7 @@ "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -2155,7 +2156,8 @@ "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.4.tgz", "integrity": "sha512-1ZIUqtPITFbv/DxRmDr5/agPqJwF69d24m9qmM1939TJehgY539CtzeZRjbLt5G6fSy/7YqqYsfvoTEw9xUI2A==", "dev": true, - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/tapable": { "version": "2.2.1", @@ -2214,6 +2216,7 @@ "integrity": "sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.3", diff --git a/resources/views/livewire/filament/buildplate.blade.php b/resources/views/livewire/filament/buildplate.blade.php index a9fc9d0..31244ec 100644 --- a/resources/views/livewire/filament/buildplate.blade.php +++ b/resources/views/livewire/filament/buildplate.blade.php @@ -22,15 +22,17 @@ Description Manufacturer Max Temp. + Amount + - @foreach ($buildplates as $buildplate)

{{ $buildplate->name }}

{{ $buildplate->description }}

-

{{ $buildplate->manufacturer_id->name }}

+

{{ App\Models\Manufacturer::find($buildplate->manufacturer_id)->name }}

{{ $buildplate->temp_max }}

+

{{ $buildplate->amount }}

@@ -40,7 +42,6 @@ @endforeach - {{ $buildplates->links() }} @@ -53,11 +54,21 @@
- Create color - Create a new color. + Create buildplate + Create a new buildplate. +
+ + + + Choose Manufacturer + @foreach ($manufacturers as $manufacturer) + {{ $manufacturer->name }} + @endforeach + +
+ +
- -
Cancel @@ -77,8 +88,18 @@ Edit buildplate Edit an existing buildplate.
- - + + + + Choose Manufacturer + @foreach ($manufacturers as $manufacturer) + {{ $manufacturer->name }} + @endforeach + +
+ + +
Cancel @@ -101,7 +122,17 @@
- + + + Choose Manufacturer + @foreach ($manufacturers as $manufacturer) + {{ $manufacturer->name }} + @endforeach + +
+ + +
Cancel diff --git a/resources/views/livewire/filament/type.blade.php b/resources/views/livewire/filament/type.blade.php index 1be3886..f730f94 100644 --- a/resources/views/livewire/filament/type.blade.php +++ b/resources/views/livewire/filament/type.blade.php @@ -12,7 +12,7 @@ - +
@@ -28,7 +28,7 @@

{{ $type->name }}

{{ $type->description }}

-

+

{{ $type->amount }}

Edit @@ -37,7 +37,7 @@ @endforeach - + {{ $types->links() }} @@ -108,4 +108,4 @@ - \ No newline at end of file +