I am using Laravel 5.3.   
There is a  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 to a member function format() on string (View: D:\wnmp\www\laravel-5-3-dev\resources\views\artiles\index.blade.php)
Why is it?
In your Article class add following property:
/**  * The attributes that should be mutated to dates.  *  * @var array  */ protected $dates = ['expired_at'];   Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With