Reputation: 683
I'm trying to learn Laravel and Livewire. Will it cause future problems if the CRUD is placed in a Livewire Component instead of a Controller?
Code inside the livewire component:
public function create()
{
$this->validate();
Page::create($this->modelData());
$this->modalFormVisible = false;
$this->reset();
}
public function read()
{
return Page::paginate(5);
}
public function update()
{
$this->validate();
Page::find($this->modelId)->update($this->modelData());
$this->modalFormVisible = false;
}
public function delete()
{
Page::destroy($this->modelId);
$this->modalConfirmDeleteVisible = false;
$this->resetPage();
}
Upvotes: 0
Views: 231
Reputation: 366
There is no problem with implementing the crud functionality within a livewire component as long as that is that livewire component's main purpose. A livewire component is just another alternative solution equal to a controller.
Upvotes: 1