我正在使用Laravel Commentable包,它使用嵌套集模式和Baum.
我设法允许用户对帖子发表评论,但他们没有线程,每个评论depth在数据库中都设置为零.
所以我想知道如何制作像reddit这样的多线程评论?
这些是我的表
users: id, name, email...
posts: id, user_id, subreddit_id...
comments: id, body, parent_id, lft, rgt, depth, commentable_id, commentable_type, user_id
Run Code Online (Sandbox Code Playgroud)
我的模特(评论和用户)
class Comment extends Model
{
use Commentable;
public function commentable()
{
return $this->morphTo();
}
public function user() {
return $this->belongsTo('App\User');
}
public function posts() {
return $this->belongsTo('App\Post');
}
}
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
public function posts() {
return $this->hasMany('App\Post');
}
public …Run Code Online (Sandbox Code Playgroud)