Initial database creation and seeding with Laravel 5 (Build a forum part 1)

Connor Leech
Employbl
Published in
6 min readApr 30, 2017

--

Laracasts video course — available here: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/1

tl;dr — Source code: https://github.com/connor11528/laravel-forum

Thank you Jeffrey Way and Laracasts for this awesome series! The full video tutorials are available here: https://laracasts.com/series/lets-build-a-forum-with-laravel

We’re going to be using Laravel 5.4.

Create application:

$ laravel new laravel-forum
$ cd laravel-forum
$ composer install

Application Structure and Models

  1. Thread
  2. Reply
  3. User
    A. Thread is created by a user
    B. A reply belongs to a thread, and belongs to a user.

Next we have a command to make the Thread model with a migration and a resourceful controller. Laravel is bundled with a command line tool called Artisan that assists us in building our application.

$ php artisan make:model Thread -mr

Next update the migration for Thread (database/migrations/<timestamp>_create_threads_table.php):

public function up()
{
Schema::create(‘threads’, function (Blueprint $table) {
$table->increments(‘id’);
$table->integer(‘user_id’);
$table->string(‘title’)…

--

--

Connor Leech
Employbl

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