<?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; use Carbon\Carbon; use App\Post; use App\User; class Comment extends Model { protected $fillable = ['content']; protected $with = ['user']; public function post() { return $this->belongsTo(Post::class); } public function user() { return $this->belongsTo(User::class); } public function getCreatedAtAttribute($value) { return Carbon::createFromTimestamp(strtotime($value))->diffForHumans(); } } Comment::saving(function ($model) { $model->user_id = Auth::user()->id; });