Add Printers and Printertypes modules with CRUD functionality, migrations, and UI components.

This commit is contained in:
2026-01-24 11:23:37 +01:00
parent 563b0e750e
commit fd61f14ffe
25 changed files with 1017 additions and 4 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Livewire\Printer;
use Livewire\Attributes\Validate;
use Livewire\Component;
use App\Models\Printer as Model;
use Livewire\Attributes\title;
#[title('Edit Printer')]
class EditPrinter extends Component
{
public Model $printer ;
public string $name = '';
public string $description = '';
public int $printertype_id = 0;
#[Validate('required')]
public function save(){
$this->validate([
'name' => ['required', 'string', 'max:255'],
'description' => ['nullable', 'string', 'max:255'],
'printertype_id' => ['required', 'integer'],
]);
$this->printertype->update([
'name' => $this->name,
'description' => $this->description,
'printertype_id' => $this->printertype_id,
]);
return $this->redirectRoute('printers.show', $this->printer->id, navigate: true);
}
public function cancel(){
return $this->redirectRoute('printers.index', navigate: true);
}
public function mount(Model $printer){
$this->printer = $printer;
$this->name = $printer->name;
$this->description = $printer->description;
$this->printertype_id = $printer->printertype_id;
}
public function render()
{
return view('livewire.printer.create', [
]);
}
}