fixed filament.blade.php
This commit is contained in:
@@ -20,6 +20,7 @@ class Filament extends Component
|
|||||||
|
|
||||||
#[Validate('required')]
|
#[Validate('required')]
|
||||||
public $name = '';
|
public $name = '';
|
||||||
|
|
||||||
public $description = '';
|
public $description = '';
|
||||||
public $diameter = '1.75';
|
public $diameter = '1.75';
|
||||||
public $color_id = '';
|
public $color_id = '';
|
||||||
@@ -44,9 +45,9 @@ class Filament extends Component
|
|||||||
$filament->name = $this->name;
|
$filament->name = $this->name;
|
||||||
$filament->description = $this->description;
|
$filament->description = $this->description;
|
||||||
$filament->diameter = $this->diameter;
|
$filament->diameter = $this->diameter;
|
||||||
$filament->color_id = Color::Find($this->color_id);
|
$filament->color_id = $this->color_id;
|
||||||
$filament->filament_type_id = Type::Find($this->type_id);
|
$filament->filament_type_id = $this->type_id;
|
||||||
$filament->manufacturer_id = Manufacturer::Find($this->manufacturer_id);
|
$filament->manufacturer_id = $this->manufacturer_id;
|
||||||
$filament->weight = $this->weight;
|
$filament->weight = $this->weight;
|
||||||
$filament->price = $this->price;
|
$filament->price = $this->price;
|
||||||
$filament->stock = $this->stock;
|
$filament->stock = $this->stock;
|
||||||
@@ -58,6 +59,14 @@ class Filament extends Component
|
|||||||
// Close the modal
|
// Close the modal
|
||||||
Flux::modal('createModal')->close();
|
Flux::modal('createModal')->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancel() {
|
||||||
|
$this->resetInputFields();
|
||||||
|
Flux::modals()->close();
|
||||||
|
}
|
||||||
|
public function resetInputFields() {
|
||||||
|
$this->reset(['name', 'description', 'diameter', 'color_id', 'type_id', 'manufacturer_id', 'weight', 'price', 'stock', 'deleteid', 'editid']);
|
||||||
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.filament.filament', [
|
return view('livewire.filament.filament', [
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ class DatabaseSeeder extends Seeder
|
|||||||
'password' => bcrypt('password')
|
'password' => bcrypt('password')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this ->call(
|
$this ->call([
|
||||||
ColorSeeder::class,
|
ColorSeeder::class,
|
||||||
ManufacturerSeeder::class
|
ManufacturerSeeder::class,
|
||||||
);
|
FilamentTypeSeeder::class
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\FilamentType as Type;
|
||||||
|
|
||||||
|
class FilamentTypeSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Create Predefined Filament Types
|
||||||
|
$filamentTypes = [
|
||||||
|
['name' => 'PLA', 'description' => 'Standard filament type.'],
|
||||||
|
['name' => 'PETG', 'description' => 'Premium filament type.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($filamentTypes as $filamentType) {
|
||||||
|
Type::create($filamentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,8 @@ class ManufacturerSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
// Create predefined Manufacturers
|
// Create predefined Manufacturers
|
||||||
$manufacturers = [
|
$manufacturers = [
|
||||||
['name' => 'Bambulab', 'description' => 'Bambulab is a manufacturer of high quality products.', 'website' => 'https://bambulab.com', 'logo' => 'https://example.com/bambulab-logo.png']
|
['name' => 'Bambulab', 'description' => 'Bambulab is a manufacturer of high quality products.', 'website' => 'https://bambulab.com', 'logo' => ''],
|
||||||
|
['name' => 'Sunlu', 'description' => 'Sunlu is a manufacturer of high quality products.', 'website' => 'https://sunlu.com', 'logo' => '']
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -28,18 +28,28 @@
|
|||||||
<x-table.header>Weight</x-table.header>
|
<x-table.header>Weight</x-table.header>
|
||||||
<x-table.header>Price</x-table.header>
|
<x-table.header>Price</x-table.header>
|
||||||
<x-table.header>Rolls</x-table.header>
|
<x-table.header>Rolls</x-table.header>
|
||||||
<x-table.header class="w-1/6"></x-table.header>
|
<x-table.header class="w-48"></x-table.header>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
@foreach ($filaments as $filament)
|
@foreach ($filaments as $filament)
|
||||||
<tr wire:key="{{ $filament->id }}" class="border-b border-blackout-950">
|
<tr wire:key="{{ $filament->id }}" class="border-b border-blackout-950">
|
||||||
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $filament->name }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3 pl-6 font-bold">{{ $filament->name }}</p></x-table.item>
|
||||||
<x-table.item><p class="p-4 px-3">{{ $filament->description }}</p></x-table.item>
|
<x-table.item><p class="p-4 px-3">{{ $filament->description }}</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-2 justify-start items-center">
|
||||||
<flux:button wire:click="edit({{ $filament->id }})" icon="pencil">Edit</flux:button>
|
<div class="p-4 px-3 mx-3 h-8 rounded w-full" style="background-color: {{ App\Models\Color::find($filament->color_id)->hex}}"></div>
|
||||||
<flux:button wire:click="deleteModal({{ $filament->id }})" icon="x-mark">Delete</flux:button>
|
<p>{{ App\Models\Color::find($filament->color_id)->name }}</p></x-table.item>
|
||||||
|
</div>
|
||||||
|
<x-table.item><p class="p-4 px-3">{{ App\Models\Manufacturer::find($filament->manufacturer_id)->name }}</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3">{{ App\Models\FilamentType::find($filament->filament_type_id)->name }}</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3">{{ $filament->diameter }} mm</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3">{{ $filament->weight }} g/m</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3">${{ $filament->price }}</p></x-table.item>
|
||||||
|
<x-table.item><p class="p-4 px-3">${{ $filament->stock }}</p></x-table.item>
|
||||||
|
<x-table.item>
|
||||||
|
<div class="flex flex-row gap-2 justify-start pr-2">
|
||||||
|
<flux:button wire:click="edit({{ $filament->id }})" variant="ghost" icon="pencil">Edit</flux:button>
|
||||||
|
<flux:button wire:click="deleteModal({{ $filament->id }})" variant="ghost" icon="x-mark">Delete</flux:button>
|
||||||
</div>
|
</div>
|
||||||
</x-table.item>
|
</x-table.item>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -62,19 +72,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<flux:input label="Name" wire:model="name" placeholder="Filament Name" required />
|
<flux:input label="Name" wire:model="name" placeholder="Filament Name" required />
|
||||||
<flux:textarea label="Description" wire:model="description" placeholder="Description" />
|
<flux:textarea label="Description" wire:model="description" placeholder="Description" />
|
||||||
<flux:select wire:model="manufacturer" label="Manufacturer">
|
<flux:select wire:model="manufacturer_id" label="Manufacturer">
|
||||||
|
<flux:select.option disabled value="">Choose Manufacturer</flux:select.option>
|
||||||
@foreach ($manufacturers as $manufacturer)
|
@foreach ($manufacturers as $manufacturer)
|
||||||
<option value="{{ $manufacturer->id }}">{{ $manufacturer->name }}</option>
|
<flux:select.option wire:key="{{ $manufacturer->id }}" value="{{ $manufacturer->id }}">{{ $manufacturer->name }}</flux:select.option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</flux:select>
|
</flux:select>
|
||||||
<flux:select wire:model="type" label="Type">
|
<flux:select wire:model="type_id" label="Type">
|
||||||
|
<flux:select.option disabled value="">Choose Type</flux:select.option>
|
||||||
@foreach ($types as $type)
|
@foreach ($types as $type)
|
||||||
<option value="{{ $type->id }}">{{ $type->name }}</option>
|
<flux:select.option wire:key="{{ $type->id }}" value="{{ $type->id }}">{{ $type->name }}</flux:select.option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</flux:select>
|
</flux:select>
|
||||||
<flux:select wire:model="color" label="Color" >
|
<flux:select wire:model="color_id" label="Color" >
|
||||||
|
<flux:select.option disabled value="">Choose Color</flux:select.option>
|
||||||
@foreach ($colors as $color)
|
@foreach ($colors as $color)
|
||||||
<option value="{{ $color->id }}">{{ $color->name }}</option>
|
<flux:select.option wire:key="{{ $color->id }}" value="{{ $color->id }}">{{ $color->name }}</flux:select.option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</flux:select>
|
</flux:select>
|
||||||
<flux:input label="Diameter" wire:model="diameter" placeholder="Diameter" required />
|
<flux:input label="Diameter" wire:model="diameter" placeholder="Diameter" required />
|
||||||
|
|||||||
Reference in New Issue
Block a user