We are all anxious to get writing some code to interact with websockets, but first we need to build the foundation of code necessary to start submitting and displaying comments to our users. Once we have this part setup, then we can easily add websockets to it to enhance the experience even more.
This episode will create a small API for us to interact with and will create some structure to save our comments.
First we need to create a database migration to store our comments. This will require creating a migration, a model, and a controller for our comments.
We will make 2 API endpoints for our comments. The first is to display all comments for a specific post. The second endpoint will allow us to save a new comment via the API.
Then its time to use this API by setting up our frontend. We will create two Vue.js methods to handle this. The first is getComments() which gets all the comments for the current post, and the second is postComments() which will post a new comment for the current post.
Next up: We actually connect websockets to display new comments onto the page as they are submitted live!
==== WRITTEN TUTORIALS ====
“Mastering Websockets in Laravel” Master Series Page:
Part 2: Setting Up Comments AJAX (Written Tutorial)
==== MORE FROM THIS SERIES . ====
Full Playlist for the “Mastering Websockets in Laravel” Series:
==== DOWNLOAD SOURCE CODE ====
Github Code Repo for this Series:
Download Source Code for this Episode:
==== FOLLOW ME ====
Subscribe for New Releases!
Subscribe to DevMarketer Insider (Email)
Twitter – http://twitter.com/_jacurtis
(ask me questions!)
==== QUESTIONS? ====
Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.
Email me email@example.com
Thanks for all your support!