53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Manufacturer;
|
|
|
|
use App\Models\Manufacturer as Model;
|
|
use Livewire\Attributes\title;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
|
|
#[title('Manufacturer List')]
|
|
class EditManufacturer extends Component{
|
|
|
|
public Model $manufacturer ;
|
|
public string $name = '';
|
|
public string $description = '';
|
|
public string $website = '';
|
|
|
|
public function mount(Model $manufacturer){
|
|
$this->manufacturer = $manufacturer;
|
|
$this->name = $manufacturer->name;
|
|
$this->description = $manufacturer->description;
|
|
$this->website = $manufacturer->website;
|
|
}
|
|
|
|
#[Validate('required')]
|
|
public function save(){
|
|
$this->validate([
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string'],
|
|
'website' => ['nullable', 'string', 'max:255']
|
|
]);
|
|
|
|
$this->manufacturer->update([
|
|
'name' => $this->name,
|
|
'description' => $this->description,
|
|
'website' => $this->website
|
|
]);
|
|
|
|
return $this->redirectRoute('manufacturer.show', $this->manufacturer->id, navigate: true);
|
|
}
|
|
|
|
public function cancel(){
|
|
return $this->redirectRoute('manufacturer.index', navigate: true);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
|
|
return view('livewire.manufacturer.edit', [
|
|
]);
|
|
}
|
|
}
|