This is a demo of Laravel Livewire for the session taken by Mitul Golakiya during Laravel Live India April 2020 Online Meetup.
We built a kind of Support ticket system where you can list the ticket, click the ticket on left side, and it will load all the comments of that ticket in the right sidebar without writing any single piece of Javascript code.
Also, you can search tickets and add new comments to the ticket without leaving a page just like and SPA (Single Page Application).
Here is the screenshot of demo application.
Here is the flow/stuff that was covered during demo.
-
Basic Project Setup
- Laravel Application
- Setup .env
- Install basic packages
- Install Livewire
-
Setup Tickets and Comments
- Create Migrations
- Create Models
- Create TicketController
- Create Seeders for some initial demo data
- Setup Layout
- Setup Tickets List View
- Setup Comments View
-
Setup Livewire Setup CSS + Script
-
Understand Component Structure
- Create First Component - TicketsWindow
- Component File + View File
-
Reactor TicketsWindow Component
- Move Blade Code to component file
- Use component in our blade view
- Pass Data by Component
-
Create TicketsList Component
- Move blade code to component file
- Pass Data to view
-
Create CommentsList Component
- Move blade code to component file
- Pass Data to view
-
Data Binding
- Public properties + mount method
- Reactor components to use public properties
-
Livewire Actions
- Add Interactions to Tickets List
- Handle Ticket Click
- Make Ticket selected
-
Livewire Events
- Render Comments of selected ticket
- Dispatch Event from Tickets List when ticket selected
- Listen event in CommentsList component
- Refresh the comments of selected ticket
-
Add Comment
- Add new comment without page refresh
-
Handle No Ticket Selection
- If not ticket has been selected then display empty state
-
Implement Search
- Define as a model
- Make search working
- Handle few bugs of selections
-
Display Comments Count
Thanks to,
- Laravel & Taylor Otwell
- Livewire & Caleb Porzio
- Mitul Golakiya as a speaker
- Laravel Live India Community for organizing this wonderful event