Build an online forum with Laravel — Post and Show Replies to Threads (Part 3)
Getting caught up
The previous blog posts and the source code are linked below:
Part 1 — Initial Setup and Seeding
Part 2 — Create routes, views, controllers. Generate auth. Write test
Let’s Build a Forum Laracast Series
- a thread can have replies. relation on model, view and tests: with this code we added a Reply model where each Reply belongs to a User. A Thread can have many Replies associated with it. We also updated the UI so that the Replies to a Particular thread show up when you click on that Thread. Additionally, we wrote tests to make sure that a user can read replies associated with a thread and to test that a reply instance has an owner that is a user. (link to code)
- a user can respond to threads: In the next commit we added methods to the Thread model so that we can easily grab the creator of the Thread and add a reply to that thread. We also fleshed out the Reply controller method to store Replies. We added the HTML with Blade syntax to render replies to the screen. We also wrote a ton of tests. (link to code)
- signed in users can post replies to threads: This is a sort commit where we added a form to post replies to the thread. (link to code)
Conclusion (for now)
First off: Sign up for Laracasts if you are not already a member.
In the current state of the application have a functional Laravel 5.4 app with mock data hooked up to SQL database. There is authentication and ability to store Users. Additionally, there are Threads and Replies. There is a Threads page where we can view all of the Threads. Each Thread is associated with one User. Each individual Thread has its own page where we can view who created the Thread and also Replies to that Thread. Users can post Replies to the Thread, but only if they are signed in. If Users are not signed in the form will be hidden.
So far I am very impressed with this series. Jeffrey Way makes the content easy to follow and engaging. He is a very clear and deliberate programmer. His videos are easy to follow. Being able to stop and start the content to code and learn at my own pace is amazing. The Laravel framework is very powerful. We have not written too many lines of code and already have a formidable application. There are tons of videos left so I will see you in the next post!