数据表有个expired_at
字段,数据是这样的:
public function store(Request $request)
{
$data=[
'expired_at'=>Carbon::now()->addDays($publishing_days)->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)
怎么回事?
在model类中这样操作 ` /**
// protected function asDateTime($value) {
// return $value;
// }