php - Laravel error:Call to a member function format() on string -


i using laravel 5.3.

there field expired_at in table articles

public function store(request $request) {     $data=[          'expired_at'=>carbon::now()->adddays(30)->endofday()     ];     $article=article::create(array_merge($request->all(),$data));      return redirect('/artilces'); } 

view:

{{$article->expired_at->format('y-m-d')}} 

error:

call member function format() on string (view: d:\wnmp\www\laravel-5-3-dev\resources\views\artiles\index.blade.php) 

why it?

in article class add following property:

/**  * attributes should mutated dates.  *  * @var array  */ protected $dates = ['expired_at']; 

docs


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -