久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='SYJeb'></bdo><ul id='SYJeb'></ul>

      <tfoot id='SYJeb'></tfoot>

      <small id='SYJeb'></small><noframes id='SYJeb'>

      <i id='SYJeb'><tr id='SYJeb'><dt id='SYJeb'><q id='SYJeb'><span id='SYJeb'><b id='SYJeb'><form id='SYJeb'><ins id='SYJeb'></ins><ul id='SYJeb'></ul><sub id='SYJeb'></sub></form><legend id='SYJeb'></legend><bdo id='SYJeb'><pre id='SYJeb'><center id='SYJeb'></center></pre></bdo></b><th id='SYJeb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SYJeb'><tfoot id='SYJeb'></tfoot><dl id='SYJeb'><fieldset id='SYJeb'></fieldset></dl></div>
        <legend id='SYJeb'><style id='SYJeb'><dir id='SYJeb'><q id='SYJeb'></q></dir></style></legend>

        如何更改 created_at 和 updated_at 值 laravel 的默認格

        How to change default format at created_at and updated_at value laravel(如何更改 created_at 和 updated_at 值 laravel 的默認格式)
        1. <tfoot id='R4s34'></tfoot>
                <tbody id='R4s34'></tbody>

              1. <legend id='R4s34'><style id='R4s34'><dir id='R4s34'><q id='R4s34'></q></dir></style></legend>
                <i id='R4s34'><tr id='R4s34'><dt id='R4s34'><q id='R4s34'><span id='R4s34'><b id='R4s34'><form id='R4s34'><ins id='R4s34'></ins><ul id='R4s34'></ul><sub id='R4s34'></sub></form><legend id='R4s34'></legend><bdo id='R4s34'><pre id='R4s34'><center id='R4s34'></center></pre></bdo></b><th id='R4s34'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='R4s34'><tfoot id='R4s34'></tfoot><dl id='R4s34'><fieldset id='R4s34'></fieldset></dl></div>

                • <bdo id='R4s34'></bdo><ul id='R4s34'></ul>

                  <small id='R4s34'></small><noframes id='R4s34'>

                  本文介紹了如何更改 created_at 和 updated_at 值 laravel 的默認格式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 Laravel 的新手.我正在使用 Laravel 創建一個應用程序.當我創建帖子時,created_at"和updated_at"的值如下所示:

                  I am new in Laravel. I am creating a application with laravel. When i creating a post then the values of "created_at" and 'updated_at" are look like this:

                  2014-06-26 04:07:31
                  2014-06-26 04:07:31
                  

                  但我希望沒有時間的這些值看起來像這樣:

                  But i want this values without time look like this :

                  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();
                  }
                  

                  請幫幫我.

                  推薦答案

                  在你的 Post 模型中添加兩??個這樣的訪問器方法:

                  In your Post model add two accessor methods like this:

                  public function getCreatedAtAttribute($date)
                  {
                      return CarbonCarbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d');
                  }
                  
                  public function getUpdatedAtAttribute($date)
                  {
                      return CarbonCarbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d');
                  }
                  

                  現在,每次您使用模型中的這些屬性來顯示日期時,這些都會以不同的方式呈現,只是不帶時間的日期,例如:

                  Now every time you use these properties from your model to show a date these will be presented differently, just the date without the time, for example:

                  $post = Post::find(1);
                  echo $post->created_at; // only Y-m-d formatted date will be displayed
                  

                  因此您無需更改數據庫中的原始類型.要更改數據庫中的 type,您需要將其從 Timestamp 更改為 Date 并且您需要從遷移中進行(如果您使用完全)或直接進入您的數據庫,如果您不使用遷移.timestamps() 方法添加這些字段(使用 Migration),要在遷移期間更改這些字段,您需要刪除 timestamps() 方法并使用 date() 代替,例如:

                  So you don't need to change the original type in the database. to change the type in your database you need to change it to Date from Timestamp and you need to do it from your migration (If your using at all) or directly into your database if you are not using migration. The timestamps() method adds these fields (using Migration) and to change these fields during the migration you need to remove the timestamps() method and use date() instead, for example:

                  $table->date('created_at');
                  $table->date('updated_at');
                  

                  這篇關于如何更改 created_at 和 updated_at 值 laravel 的默認格式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  • <bdo id='xa5c5'></bdo><ul id='xa5c5'></ul>

                        <tbody id='xa5c5'></tbody>

                    • <tfoot id='xa5c5'></tfoot>
                      <legend id='xa5c5'><style id='xa5c5'><dir id='xa5c5'><q id='xa5c5'></q></dir></style></legend>
                    • <i id='xa5c5'><tr id='xa5c5'><dt id='xa5c5'><q id='xa5c5'><span id='xa5c5'><b id='xa5c5'><form id='xa5c5'><ins id='xa5c5'></ins><ul id='xa5c5'></ul><sub id='xa5c5'></sub></form><legend id='xa5c5'></legend><bdo id='xa5c5'><pre id='xa5c5'><center id='xa5c5'></center></pre></bdo></b><th id='xa5c5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xa5c5'><tfoot id='xa5c5'></tfoot><dl id='xa5c5'><fieldset id='xa5c5'></fieldset></dl></div>

                          1. <small id='xa5c5'></small><noframes id='xa5c5'>

                            主站蜘蛛池模板: 一区二区三区在线免费观看视频 | 欧美色图另类 | 国产免费一区 | 日韩二三区 | 成人午夜免费福利视频 | www.日韩系列 | 男女网站免费 | 天天爽夜夜爽精品视频婷婷 | 久久国产精品久久久久久 | 亚洲成人在线免费 | 国产成人精品午夜 | 免费国产一区二区 | 国产成人免费视频网站高清观看视频 | 精品欧美色视频网站在线观看 | 国产精品一区二区无线 | 国产成人精品一区二区 | 中文字幕 在线观看 | 99久9| 国产一二区免费视频 | 日韩成人免费视频 | 伊人狠狠操 | 嫩草影院网址 | 成人免费网站视频 | 日韩电影中文字幕 | 黄色免费网址大全 | 黄视频网站免费观看 | 日本特黄a级高清免费大片 国产精品久久性 | 精品久久久久久 | 久久久久国产精品一区 | 在线免费观看亚洲 | 亚州无限乱码 | 老司机67194精品线观看 | 久久精品国产一区二区 | 久久精品在线免费视频 | 久草免费在线视频 | 欧美黑人一级爽快片淫片高清 | 中文在线a在线 | 亚洲精品视频一区二区三区 | 日韩精品一区二区三区视频播放 | av黄色免费在线观看 | 久久夜色精品国产 |