Updated Buildplate Forms
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Livewire\Filament;
|
namespace App\Livewire\Filament;
|
||||||
|
|
||||||
|
use App\Models\Manufacturer as Manufacturer;
|
||||||
use Flux\Flux;
|
use Flux\Flux;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Livewire\Attributes\Title;
|
use Livewire\Attributes\Title;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
@@ -16,6 +18,10 @@ class Buildplate extends Component
|
|||||||
|
|
||||||
#[Validate('required')]
|
#[Validate('required')]
|
||||||
public $name = '';
|
public $name = '';
|
||||||
|
public $description = '';
|
||||||
|
public $manufacturer_id = '';
|
||||||
|
public $temp_max = '';
|
||||||
|
public $amount = '';
|
||||||
|
|
||||||
public $search ='';
|
public $search ='';
|
||||||
|
|
||||||
@@ -25,10 +31,82 @@ class Buildplate extends Component
|
|||||||
public $editid = '';
|
public $editid = '';
|
||||||
public $deleteid = '';
|
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()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.filament.buildplate', [
|
return view('livewire.filament.buildplate', [
|
||||||
'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20)
|
'buildplates' => BuildplateModel::search('name', $this->search)->paginate(20),
|
||||||
|
'manufacturers' => Manufacturer::all(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class Type extends Component
|
|||||||
public $editid = '';
|
public $editid = '';
|
||||||
public $deleteid = '';
|
public $deleteid = '';
|
||||||
|
|
||||||
|
public $amount = '0';
|
||||||
|
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
@Auth::check();
|
@Auth::check();
|
||||||
@@ -108,6 +110,7 @@ class Type extends Component
|
|||||||
{
|
{
|
||||||
return view('livewire.filament.type', [
|
return view('livewire.filament.type', [
|
||||||
'types' => FilamentType::search('name', $this->search)->paginate(10)
|
'types' => FilamentType::search('name', $this->search)->paginate(10)
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ class Buildplate extends Model
|
|||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'manufacturer_id',
|
'manufacturer_id',
|
||||||
'temp_max'
|
'temp_max',
|
||||||
|
'amount'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function filament()
|
public function filament()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ return new class extends Migration
|
|||||||
$table->string('description');
|
$table->string('description');
|
||||||
$table->foreignId('manufacturer_id')->constrained();
|
$table->foreignId('manufacturer_id')->constrained();
|
||||||
$table->string('temp_max');
|
$table->string('temp_max');
|
||||||
|
$table->string('amount');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class BuildplateSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
// Create Predefined Filament Types
|
// Create Predefined Filament Types
|
||||||
$buildplates = [
|
$buildplates = [
|
||||||
['name' => 'Supertrack', 'description' => 'Standard 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],
|
['name' => 'Smooth PEI', 'description' => 'Premium filament type.', 'manufacturer_id' => 1, 'temp_max' => 230, 'amount' => 1],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($buildplates as $buildplate) {
|
foreach ($buildplates as $buildplate) {
|
||||||
|
|||||||
Generated
+4
-1
@@ -1966,6 +1966,7 @@
|
|||||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -2155,7 +2156,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.4.tgz",
|
||||||
"integrity": "sha512-1ZIUqtPITFbv/DxRmDr5/agPqJwF69d24m9qmM1939TJehgY539CtzeZRjbLt5G6fSy/7YqqYsfvoTEw9xUI2A==",
|
"integrity": "sha512-1ZIUqtPITFbv/DxRmDr5/agPqJwF69d24m9qmM1939TJehgY539CtzeZRjbLt5G6fSy/7YqqYsfvoTEw9xUI2A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
@@ -2214,6 +2216,7 @@
|
|||||||
"integrity": "sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg==",
|
"integrity": "sha512-ZSvGOXKGceizRQIZSz7TGJ0pS3QLlVY/9hwxVh17W3re67je1RKYzFHivZ/t0tubU78Vkyb9WnHPENSBCzbckg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.25.0",
|
"esbuild": "^0.25.0",
|
||||||
"fdir": "^6.4.3",
|
"fdir": "^6.4.3",
|
||||||
|
|||||||
@@ -22,15 +22,17 @@
|
|||||||
<x-table.header>Description</x-table.header>
|
<x-table.header>Description</x-table.header>
|
||||||
<x-table.header>Manufacturer</x-table.header>
|
<x-table.header>Manufacturer</x-table.header>
|
||||||
<x-table.header>Max Temp.</x-table.header>
|
<x-table.header>Max Temp.</x-table.header>
|
||||||
|
<x-table.header>Amount</x-table.header>
|
||||||
|
<x-table.header></x-table.header>
|
||||||
<x-table.header class="w-1/6"></x-table.header>
|
<x-table.header class="w-1/6"></x-table.header>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
@foreach ($buildplates as $buildplate)
|
@foreach ($buildplates as $buildplate)
|
||||||
<tr wire:key="{{ $buildplate->id }}" class="border-b border-blackout-950">
|
<tr wire:key="{{ $buildplate->id }}" class="border-b border-blackout-950">
|
||||||
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $buildplate->name }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $buildplate->name }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3">{{ $buildplate->description }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3">{{ $buildplate->description }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3">{{ $buildplate->manufacturer_id->name }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3">{{ App\Models\Manufacturer::find($buildplate->manufacturer_id)->name }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3 text-left">{{ $buildplate->temp_max }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3 text-left">{{ $buildplate->temp_max }}</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3 text-left">{{ $buildplate->amount }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3"></p></x-table.item>
|
<x-table.item><p class="p-4 px-3"></p></x-table.item>
|
||||||
<x-table.item>
|
<x-table.item>
|
||||||
<div class="flex flex-row gap-4 justify-end pr-8">
|
<div class="flex flex-row gap-4 justify-end pr-8">
|
||||||
@@ -40,7 +42,6 @@
|
|||||||
</x-table.item>
|
</x-table.item>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
<x-slot name="pagination">
|
<x-slot name="pagination">
|
||||||
{{ $buildplates->links() }}
|
{{ $buildplates->links() }}
|
||||||
</x-slot>
|
</x-slot>
|
||||||
@@ -53,11 +54,21 @@
|
|||||||
<form wire:submit.prevent="create">
|
<form wire:submit.prevent="create">
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<flux:heading size="lg" class="text-nuke-400">Create color</flux:heading>
|
<flux:heading size="lg" class="text-nuke-400">Create buildplate</flux:heading>
|
||||||
<flux:text class="mt-2">Create a new color.</flux:text>
|
<flux:text class="mt-2">Create a new buildplate.</flux:text>
|
||||||
|
</div>
|
||||||
|
<flux:input label="Name" wire:model="name" placeholder="Buildplate Name" required />
|
||||||
|
<flux:textarea label="Description" wire:model="description" placeholder="Description" />
|
||||||
|
<flux:select wire:model="manufacturer_id" label="Manufacturer">
|
||||||
|
<flux:select.option disabled value="">Choose Manufacturer</flux:select.option>
|
||||||
|
@foreach ($manufacturers as $manufacturer)
|
||||||
|
<flux:select.option wire:key="{{ $manufacturer->id }}" value="{{ $manufacturer->id }}">{{ $manufacturer->name }}</flux:select.option>
|
||||||
|
@endforeach
|
||||||
|
</flux:select>
|
||||||
|
<div class="grid grid-cols-2 gap-x-4 gap-y-6">
|
||||||
|
<flux:input label="Temperature" wire:model="temp_max" placeholder="Temperature" required />
|
||||||
|
<flux:input label="Amount" wire:model="amount" placeholder="Amount" required />
|
||||||
</div>
|
</div>
|
||||||
<flux:input label="Name" wire:model="name" placeholder="Color Name" required />
|
|
||||||
<flux:input label="hex" wire:model="hex" type="color" required />
|
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<flux:spacer />
|
<flux:spacer />
|
||||||
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
||||||
@@ -77,8 +88,18 @@
|
|||||||
<flux:heading size="lg" class="text-etheral-300">Edit buildplate</flux:heading>
|
<flux:heading size="lg" class="text-etheral-300">Edit buildplate</flux:heading>
|
||||||
<flux:text class="mt-2">Edit an existing buildplate.</flux:text>
|
<flux:text class="mt-2">Edit an existing buildplate.</flux:text>
|
||||||
</div>
|
</div>
|
||||||
<flux:input label="Name" wire:model="name" placeholder="Color Name" required />
|
<flux:input label="Name" wire:model="name" placeholder="Buildplate Name" required />
|
||||||
<flux:input label="hex" wire:model="hex" type="color" required />
|
<flux:textarea label="Description" wire:model="description" placeholder="Description" />
|
||||||
|
<flux:select wire:model="manufacturer_id" label="Manufacturer">
|
||||||
|
<flux:select.option disabled value="">Choose Manufacturer</flux:select.option>
|
||||||
|
@foreach ($manufacturers as $manufacturer)
|
||||||
|
<flux:select.option wire:key="{{ $manufacturer->id }}" value="{{ $manufacturer->id }}">{{ $manufacturer->name }}</flux:select.option>
|
||||||
|
@endforeach
|
||||||
|
</flux:select>
|
||||||
|
<div class="grid grid-cols-2 gap-x-4 gap-y-6">
|
||||||
|
<flux:input label="Temperature" wire:model="temp_max" placeholder="Temperature" required />
|
||||||
|
<flux:input label="Amount" wire:model="amount" placeholder="Amount" required />
|
||||||
|
</div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<flux:spacer />
|
<flux:spacer />
|
||||||
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
||||||
@@ -101,7 +122,17 @@
|
|||||||
</flux:text>
|
</flux:text>
|
||||||
</div>
|
</div>
|
||||||
<flux:input label="Name" wire:model="name" disabled placeholder="Buildplate Name" required />
|
<flux:input label="Name" wire:model="name" disabled placeholder="Buildplate Name" required />
|
||||||
<flux:input label="hex" wire:model="hex" disabled type="color" required />
|
<flux:textarea label="Description" wire:model="description" disabled placeholder="Description" />
|
||||||
|
<flux:select wire:model="manufacturer_id" disabled label="Manufacturer">
|
||||||
|
<flux:select.option disabled value="">Choose Manufacturer</flux:select.option>
|
||||||
|
@foreach ($manufacturers as $manufacturer)
|
||||||
|
<flux:select.option wire:key="{{ $manufacturer->id }}" value="{{ $manufacturer->id }}">{{ $manufacturer->name }}</flux:select.option>
|
||||||
|
@endforeach
|
||||||
|
</flux:select>
|
||||||
|
<div class="grid grid-cols-2 gap-x-4 gap-y-6">
|
||||||
|
<flux:input label="Temperature" wire:model="temp_max" disabled placeholder="Temperature" required />
|
||||||
|
<flux:input label="Amount" wire:model="amount" disabled placeholder="Amount" required />
|
||||||
|
</div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<flux:spacer />
|
<flux:spacer />
|
||||||
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
<flux:button variant="ghost" wire:click='cancel'>Cancel</flux:button>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<tr wire:key="{{ $type->id }}" class="border-b border-blackout-950">
|
<tr wire:key="{{ $type->id }}" class="border-b border-blackout-950">
|
||||||
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $type->name }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $type->name }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3">{{ $type->description }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3">{{ $type->description }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3"></p></x-table.item>
|
<x-table.item><p class="p-4 px-3">{{ $type->amount }}</p></x-table.item>
|
||||||
<x-table.item>
|
<x-table.item>
|
||||||
<div class="flex flex-row gap-4 justify-end pr-8">
|
<div class="flex flex-row gap-4 justify-end pr-8">
|
||||||
<flux:button wire:click="edit({{ $type->id }})" icon="pencil">Edit</flux:button>
|
<flux:button wire:click="edit({{ $type->id }})" icon="pencil">Edit</flux:button>
|
||||||
|
|||||||
Reference in New Issue
Block a user