You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
504 B
28 lines
504 B
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Comment extends Model
|
|
{
|
|
protected $fillable = [
|
|
'body',
|
|
'url',
|
|
'user_id',
|
|
'commentable_id', // 相关联模型主键
|
|
'commentable_type', // 相关联模型名称
|
|
];
|
|
|
|
public function commentable()
|
|
{
|
|
// 多态
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne('App\Model\User', 'id', 'user_id');
|
|
}
|
|
}
|