To carry out CRUD operations for multiple tables in a single view
I'm on Laravel 8 with Livewire, currently have 3 models, Category, SubCategory and MenuItem for 3 tables. All the above models have separate livewire controllers and have the code for the CRUD operations respectively. I have separate views and routes to edit the above tables and they all have a eloquent relationship between each other. Now what I need to do here to is, I need to display all the three tables in a single view to carry out the CRUD operations. Please help me with this. Thanks a lot for your time!
@toxifiedm create instances of all the 3 models in your controller or livewire class then echo that data in your view in a tabular format. Then add buttons to edit and delete each instance and maybe a modal to create each model
@loyd Hey Loyd, thanks for the revert! So I have separate controllers for all the three models. So I have initialized several functions for different operations. Lets take an example for the store operation function.
So what I need to ask here is, do I need to merge the code from the other two controllers for the above operation under the public function store() or I can initialize the store function for the other controllers with a different name?
I achieved the said above result by using the components feature in livewire, embedded the three components for three tables, without merging the controllers, clean and yet maintainable, thanks anyways :)