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

  2. <small id='OmCZo'></small><noframes id='OmCZo'>

      更改 Laravel 的 created_at 和 updated_at 的名称

      Change name of Laravel#39;s created_at and updated_at(更改 Laravel 的 created_at 和 updated_at 的名称)
        <tbody id='LQC2n'></tbody>

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

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

            <tfoot id='LQC2n'></tfoot>
                <bdo id='LQC2n'></bdo><ul id='LQC2n'></ul>
                本文介绍了更改 Laravel 的 created_at 和 updated_at 的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我可以从以下位置映射 Laravel 的时间戳吗:

                Can I map Laravel's timestamps from:

                created_atpost_datepost_date_gmt?

                updated_atpost_modifiedpost_modified_gmt?

                我正在将一个 Wordpress 应用程序迁移到 Laravel.

                I'm migrating a Wordpress application to Laravel.

                我正在使用 Laravel 访问 Wordpress 数据库的副本.数据库的实时版本仍在使用中,所以我不想更改架构.

                I'm accessing a copy of the Wordpress database using Laravel. The live version of the database is still in use so I don't want to change the schema.

                Posts 表有 post_datepost_date_gmtpost_modifiedpost_modified_gmt,但 Laravel 需要 created_atupdated_at.

                The Posts table has post_date, post_date_gmt, post_modified and post_modified_gmt, but Laravel is expecting created_at and updated_at.

                是否可以更改 Laravel 查找的列名?

                Is there anyway to change the column names that Laravel looks for?

                我希望 Laravel 更新所有已经存在的列的时间戳.

                I'd like Laravel to update the timestamps of all the columns that are already there.

                推荐答案

                不幸的是,接受的答案可能会导致更新时间戳出现问题.

                The accepted answer may cause problems with updating timestamps unfortunately.

                您最好覆盖模型上的 const:

                You'd better override consts on your model:

                const CREATED_AT = 'post_date';
                const UPDATED_AT = 'post_modified';
                

                then 方法 getCreatedAtColumngetUpdatedAtColumn 将分别返回 post_datepost_modified,但不会造成任何伤害.

                then methods getCreatedAtColumn and getUpdatedAtColumn will return post_date and post_modified respectively, but won't do any harm.

                对于其他列,您需要使用 @Oni 建议的事件.

                For the other columns you need use events like @Oni suggested.

                这篇关于更改 Laravel 的 created_at 和 updated_at 的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <tfoot id='MTeKp'></tfoot>

                    <tbody id='MTeKp'></tbody>

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

                        <bdo id='MTeKp'></bdo><ul id='MTeKp'></ul>
                        <legend id='MTeKp'><style id='MTeKp'><dir id='MTeKp'><q id='MTeKp'></q></dir></style></legend>

                          <i id='MTeKp'><tr id='MTeKp'><dt id='MTeKp'><q id='MTeKp'><span id='MTeKp'><b id='MTeKp'><form id='MTeKp'><ins id='MTeKp'></ins><ul id='MTeKp'></ul><sub id='MTeKp'></sub></form><legend id='MTeKp'></legend><bdo id='MTeKp'><pre id='MTeKp'><center id='MTeKp'></center></pre></bdo></b><th id='MTeKp'></th></span></q></dt></tr></i><div id='MTeKp'><tfoot id='MTeKp'></tfoot><dl id='MTeKp'><fieldset id='MTeKp'></fieldset></dl></div>