Build an online forum with Laravel — Post and Show Replies to Threads (Part 3)

Connor Leech
Employbl
Published in
3 min readMay 23, 2017

--

Laracast lesson: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/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

Source Code on Github.

Let’s Build a Forum Laracast Series

This series follows the Let’s Build A Forum with Laravel and TDD Laracast series. I coded out the part 3 section from this video. For my own notes mainly here are the commits of what we covered:

  • 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

--

--

Connor Leech
Employbl

Girl Dad x 2. Cofounder @Employbl. Software Engineer @CommentSold.