56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Extruder;
|
|
|
|
use App\Models\Extruder as Model;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
#[title('Extruders')]
|
|
class EditExtruder extends Component
|
|
{
|
|
public Model $extruder ;
|
|
public string $name = '';
|
|
public string $description = '';
|
|
public int $manufacturer_id = 0;
|
|
public string $diameter = '';
|
|
public string $temp_max = '';
|
|
|
|
public function mount(Model $extruder){
|
|
$this->extruder = $extruder;
|
|
$this->name = $extruder->name;
|
|
$this->description = $extruder->description;
|
|
$this->manufacturer_id = $extruder->manufacturer_id;
|
|
$this->diameter = $extruder->diameter;
|
|
$this->temp_max = $extruder->temp_max;
|
|
}
|
|
|
|
public function save(){
|
|
$this->validate([
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string', 'max:255'],
|
|
'manufacturer_id' => ['required', 'integer'],
|
|
'diameter' => ['required', 'string', 'max:4'],
|
|
'temp_max' => ['required', 'integer']
|
|
]);
|
|
|
|
$this->extruder->update([
|
|
'name' => $this->name,
|
|
'description' => $this->description,
|
|
'manufacturer_id' => $this->manufacturer_id,
|
|
'diameter' => $this->diameter,
|
|
'temp_max' => $this->temp_max
|
|
]);
|
|
return $this->redirectRoute('extruder.show', $this->extruder->id, navigate: true);
|
|
}
|
|
public function cancel(){
|
|
return $this->redirectRoute('extruder.index', navigate: true);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.extruder.edit', [
|
|
]);
|
|
}
|
|
}
|