Refactored Manufacturer and Buildplate Livewire components. Introduced create, edit, and show components with route-based navigation. Updated views for consistency and cleaned up unused modals and legacy code. Adjusted styles and table layouts.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Buildplate;
|
||||
|
||||
use App\Models\Buildplate as Model;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
|
||||
#[title('Buildplates')]
|
||||
class EditBuildplate extends Component
|
||||
{
|
||||
public Model $buildplate ;
|
||||
public string $name = '';
|
||||
public string $description = '';
|
||||
public int $manufacturer_id = 0;
|
||||
public string $temp_max = '';
|
||||
|
||||
public function mount(Model $buildplate){
|
||||
$this->buildplate = $buildplate;
|
||||
$this->name = $buildplate->name;
|
||||
$this->description = $buildplate->description;
|
||||
$this->manufacturer_id = $buildplate->manufacturer_id;
|
||||
$this->temp_max = $buildplate->temp_max;
|
||||
}
|
||||
|
||||
public function save(){
|
||||
$this->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'description' => ['nullable', 'string', 'max:255'],
|
||||
'manufacturer_id' => ['required', 'integer'],
|
||||
'temp_max' => ['required', 'integer']
|
||||
]);
|
||||
|
||||
$this->buildplate->update([
|
||||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'manufacturer_id' => $this->manufacturer_id,
|
||||
'temp_max' => $this->temp_max
|
||||
]);
|
||||
return $this->redirectRoute('livewire.buildplate.show', $this->buildplate->id, navigate: true);
|
||||
}
|
||||
public function cancel(){
|
||||
return $this->redirectRoute('buildplate.index', navigate: true);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.buildplate.edit', [
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user