Video::class, ]; protected $append=[ ]; public function commentable(){ return $this->morphTo('commentable',self::$alias); } public function user(){ return $this->belongsTo(User::class); } /** system */ protected static function init() { self::afterInsert(function (self $comment){ if($comment->commentable_type=='video'){ $info=Video::find($comment->commentable_id); $info && $info->setInc('comment_num'); } }); self::afterDelete(function (self $comment){ }); } }