Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (21 sloc) 529 Bytes
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
protected $guarded = [];
protected $appends = ['formatted_created_at'];
public function article()
{
return $this->belongsTo('App\Article');
}
public function creator()
{
return $this->belongsTo('App\User', 'user_id')
->select(['id', 'name']);
}
public function getFormattedCreatedAtAttribute()
{
return $this->created_at->diffForHumans();
}
}