Laravel controllers vs Livewire Components as controller

Hi All!

I want to use controllers for storing data into the database (crud operations), and use the Livewire component for filters, sorting, etc. Is this good practice? Any recommendations on how to properly do this?

Hi! I think yes. I made both type of component normal and LW and both are OK.
Have a look: https://laravel-livewire.com/docs/2.x/alpine-js#creating-a-datepicker

Hey, @nikola-n

You can do that yes. When you require livewire into your project, you are not forced to use it everywhere, and you can use it Just in a few parts, and it’s OK.

So you can continue yousing controllers as you normally do and use livewire when you need it. It’s like using VueJS in few parts of your application or using Ajax request in other parts …

I have a similar question. I’ve just begun to create a standard laravel app with standard controllers and also leveraging livewire components. On the first page I have a component to make a search, I’ve made use of livewire to fetch search criteria data. On the next page I want to submit a search request to an external API using the search criteria from page 1. In this case I believe I can’t pass data between livewire components on separate pages. And therefore, I’ll just use a standard laravel controller to return the search results. Does this sound correct? If so, are livewires 2 main uses: 1) using in ‘part of your applications’, as mentioned by skywalker, 2) also to use when an app is all on one page?

Hey, @u843867

Can you show us a code example for better understanding for your situation?

there’s nothing meaningful that I can share just now. However, I’ve had thought. Instead creating a standard laravel multipage app, I can have a single page with multiple livewire component/views and use Alpine JS to show/hide the views as required?

Yeah, actually you can do that. Use a normal controller to controller the view and inside the blade file use livewire components to control the data.