Add Spareparts module with CRUD functionality and UI components.

This commit is contained in:
2026-01-24 10:15:45 +01:00
parent af0cf8bed9
commit 563b0e750e
18 changed files with 502 additions and 9 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Livewire\Sparepart;
use Livewire\Attributes\Validate;
use Livewire\Component;
use App\Models\Sparepart as Model;
use Livewire\Attributes\title;
#[title('Edit Sparepart')]
class EditSparepart extends Component
{
public Model $sparepart ;
public string $name = '';
public string $description = '';
public int $manufacturer_id = 0;
#[Validate('required')]
public function save(){
$this->validate([
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string', 'max:255'],
'manufacturer_id' => ['required', 'integer'],
]);
$this->sparepart->update([
'name' => $this->name,
'description' => $this->description,
'manufacturer_id' => $this->manufacturer_id
]);
return $this->redirectRoute('spareparts.show', $this->sparepart->id, navigate: true);
}
public function cancel(){
return $this->redirectRoute('spareparts.index', navigate: true);
}
public function mount(Model $sparepart){
$this->filament = $sparepart;
$this->name = $sparepart->name;
$this->description = $sparepart->description;
$this->manufacturer_id = $sparepart->manufacturer_id;
}
public function render()
{
return view('livewire.sparepart.create', [
]);
}
}