【发布时间】:2020-02-07 04:57:22
【问题描述】:
我正在使用laravel polymorphic relationship
我的Comment.php 班级
namespace App;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
protected $fillable = ['body', 'commentable_id', 'commentable_type'];
/**
* Get the owning commentable model.
*/
public function commentable()
{
return $this->morphTo();
}
// public function commentFrom()
// {
// return where it commented from.
// }
}
我想要什么:我想要所有评论,以及评论(帖子/视频)的来源。
【问题讨论】:
标签: laravel eloquent polymorphic-associations