laravel教程第9篇中published_at属性

首先在Article.php中已经将published_at设置成Carbon对象了,

public function setPublishedAtAttribute($date)
    {
        $this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $date);
    }

但是在ArticlesController中的index方法渲染view时,即显示主页面提示

Call to a member function diffForHumans() on a non-object

错误,index.blade.php中ul一块的代码是直接拷贝博客(手写了怕没找到错误)

@extends('app')
@foreach($articles as $article)
 <article class="format-image group">
  <h2 class="post-title pad">
   <a href="/articles/{ $article->id }"> { $article->title }</a>
  </h2>
  <ul class="post-meta pad group">
   <li><i class="fa fa-clock-o"></i>{ $article->published_at->diffForHumans() }</li>
   @if($article->tags)
    @foreach($article->tags as $tag)
     <li><i class="fa fa-tag"></i>{ $tag->name }</li>
    @endforeach
   @endif
  </ul>
  <div class="post-inner">
   <div class="post-deco">
    <div class="hex hex-small">
     <div class="hex-inner"><i class="fa"></i></div>
     <div class="corner-1"></div>
     <div class="corner-2"></div>
    </div>
   </div>
   <div class="post-content pad">
    <div class="entry custome">
     { $article->intro }
    </div>
    <a class="more-link-custom" href="/articles/{ $article->id }"><span><i>更多</i></span></a>
   </div>
  </div>
 </article>
@endforeach

求大大帮助!

JellyBool
修改的评论也不能少于六个字哦!