Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Created October 19, 2020 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryWonder/6d0729cf93f9bd2b7d6e2cf0ce88a7cf to your computer and use it in GitHub Desktop.
Save harryWonder/6d0729cf93f9bd2b7d6e2cf0ce88a7cf to your computer and use it in GitHub Desktop.
This is the forum model for the ld-fullstack blog topic
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Forum extends Model
{
protected $fillable = ['id', 'user_id', 'title', 'content', 'likes', 'comments', 'created_at', 'updated_at'];
public function commentModel()
{
return $this->hasMany('App\Comment', 'forum_id');
}
public function user()
{
return $this->belongsTo('App\User');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment