fixed create filament
This commit is contained in:
@@ -60,6 +60,77 @@ class Filament extends Component
|
||||
Flux::modal('createModal')->close();
|
||||
}
|
||||
|
||||
public function edit($filamentid) {
|
||||
@Auth::check();
|
||||
|
||||
$editid = $filamentid;
|
||||
$this->editid = $editid;
|
||||
|
||||
$filament = Model::findOrFail($editid);
|
||||
|
||||
$this->name = $filament->name;
|
||||
$this->description = $filament->description;
|
||||
$this->diameter = $filament->diameter;
|
||||
$this->color_id = $filament->color_id;
|
||||
$this->type_id = $filament->filament_type_id;
|
||||
$this->manufacturer_id = $filament->manufacturer_id;
|
||||
$this->weight = $filament->weight;
|
||||
$this->price = $filament->price;
|
||||
$this->stock = $filament->stock;
|
||||
|
||||
Flux::modal('editModal')->show();
|
||||
}
|
||||
public function save($editid) {
|
||||
@Auth::check();
|
||||
|
||||
$filament = Model::findOrFail($editid);
|
||||
$filament->name = $this->name;
|
||||
$filament->description = $this->description;
|
||||
$filament->diameter = $this->diameter;
|
||||
$filament->color_id = $this->color_id;
|
||||
$filament->filament_type_id = $this->type_id;
|
||||
$filament->manufacturer_id = $this->manufacturer_id;
|
||||
$filament->weight = $this->weight;
|
||||
$filament->price = $this->price;
|
||||
$filament->stock = $this->stock;
|
||||
$filament->save();
|
||||
|
||||
$this->resetInputFields();
|
||||
|
||||
Flux::modal('editModal')->close();
|
||||
}
|
||||
|
||||
public function deleteModal($filamentid) {
|
||||
@Auth::check();
|
||||
|
||||
$deleteid = $filamentid;
|
||||
$this->deleteid = $deleteid;
|
||||
|
||||
$filament = Model::findOrFail($deleteid);
|
||||
$this->name = $filament->name;
|
||||
$this->description = $filament->description;
|
||||
$this->diameter = $filament->diameter;
|
||||
$this->color_id = $filament->color_id;
|
||||
$this->type_id = $filament->filament_type_id;
|
||||
$this->manufacturer_id = $filament->manufacturer_id;
|
||||
$this->weight = $filament->weight;
|
||||
$this->price = $filament->price;
|
||||
$this->stock = $filament->stock;
|
||||
|
||||
Flux::modal('deleteModal')->show();
|
||||
}
|
||||
public function delete($deleteid) {
|
||||
@Auth::check();
|
||||
|
||||
$filament = Model::findOrFail($deleteid)->delete();
|
||||
|
||||
$this->deleteid = $deleteid;
|
||||
Flux::modal('deleteModal')->close();
|
||||
|
||||
// Clear the form
|
||||
$this->resetInputFields();
|
||||
}
|
||||
|
||||
public function cancel() {
|
||||
$this->resetInputFields();
|
||||
Flux::modals()->close();
|
||||
@@ -70,7 +141,7 @@ class Filament extends Component
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.filament.filament', [
|
||||
'filaments' => Model::search('name', $this->search)->paginate(10),
|
||||
'filaments' => Model::search('name', $this->search)->paginate(50),
|
||||
'colors' => Color::all(),
|
||||
'manufacturers' => Manufacturer::all(),
|
||||
'types' => Type::all()
|
||||
|
||||
Reference in New Issue
Block a user