如何更改created_at的默认格式,并updated_at值 laravel
我是拉拉维尔的新手。我正在使用laravel创建一个应用程序。当我创建一个帖子时,“created_at”和“updated_at”的值如下所示:
2014-06-26 04:07:31
2014-06-26 04:07:31
但是我希望这个值没有时间看起来像这样:
2014-06-26
2014-06-26
只有日期没有时间。
???
请帮帮我。
我的帖子模型:
<?php
class Post extends \Eloquent {
protected $fillable = array('title', 'body', 'meta','reporter', 'slug', 'image','top');
public static $rules = array(
'title'=>'required|min:2',
'body'=>'required|min:20',
'reporter'=> 'required|min:2',
'image'=>'image|mimes:jpeg,jpg,bmp,png,gif'
);
public function categories()
{
return $this->belongsToMany('Category');
}
}
我的后控制器存储:
public function store()
{
$validator = Validator::make(Input::all(), Post::$rules);
if ($validator->passes()) {
$post = new Post;
$post->title = Input::get('title');
$post->body = Input::get('body');
$post->reporter = Input::get('reporter');
$post->meta = Input::get('meta');
$post->slug = Input::get('title');
$post->top = Input::get('top');
$image = Input::file('image');
if ($image) {
$filename = date('Y-m-d-H:i:s')."-".$image->getClientOriginalName();
Image::make($image->getRealPath())->resize(250, 145)->save('public/images/postimages/'.$filename);
$post->image = 'images/postimages/'.$filename;
}
$categories = Input::get('categories');
$post->save();
$post->categories()->sync($categories);
return Redirect::route('admin.posts.index')
->with('message', 'Product Created');
}
return Redirect::back()
->with('message', 'Something went wrong')
->withErrors($validator)
->withInput();
}
请帮帮我。