41 lines
1.0 KiB
PHP
41 lines
1.0 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 CreateManufacturer extends Component{
|
|
|
|
public Model $manufacturer ;
|
|
public string $name = '';
|
|
public string $description = '';
|
|
public string $website = '';
|
|
|
|
#[Validate('required')]
|
|
public function save(){
|
|
$this->validate([
|
|
'name' => ['required', 'string', 'max:255'],
|
|
'description' => ['nullable', 'string'],
|
|
'website' => ['nullable', 'string', 'max:255']
|
|
]);
|
|
|
|
$manufacturer = new Model();
|
|
$manufacturer->name = $this->name;
|
|
$manufacturer->description = $this->description;
|
|
$manufacturer->website = $this->website;
|
|
$manufacturer->save();
|
|
|
|
return redirect()->route('manufacturer.index');
|
|
}
|
|
public function render()
|
|
{
|
|
|
|
return view('livewire.manufacturer.create', [
|
|
]);
|
|
}
|
|
}
|