我努力改变它们由使用“artisan migrate”时,如何更改时间戳列名称?
php artisan migrate
命令生成的时间戳列名。
我已经做了如下修改。当我使用雄辩的查询生成器时,它可以正确生成列名,但是当我使用上面的命令时,它仍然会生成“created_at”,“updated_at”和“deleted_at”。谁能帮我吗?非常感谢。
/* vendor\framework\src\Illuminate\Database\Eloquent\Model.php */
/**
* The name of the "created at" column.
*
* @var string
*/
const CREATED_AT = 'datetime_created';
/**
* The name of the "updated at" column.
*
* @var string
*/
const UPDATED_AT = 'datetime_updated';
/**
* The name of the "deleted at" column.
*
* @var string
*/
const DELETED_AT = 'datetime_deleted';
/* vendor\framework\src\Illuminate\Database\Schema\Blueprint.php */
/**
* Indicate that the timestamp columns should be dropped.
*
* @return void
*/
public function dropTimestamps()
{
$this->dropColumn('datetime_created', 'datetime_updated');
}
/**
* Add a "deleted at" timestamp for the table.
*
* @return void
*/
public function softDeletes()
{
$this->timestamp('datetime_deleted')->nullable();
}
/**
* Add creation and update timestamps to the table.
*
* @return void
*/
public function timestamps()
{
$this->timestamp('datetime_created');
$this->timestamp('datetime_updated');
}
/**
* Add a "deleted at" timestamp for the table.
*
* @return void
*/
public function softDeletes()
{
$this->timestamp('datetime_deleted')->nullable();
}
附:我知道修改“核心”并不是一个好主意。如果有人能告诉我扩展这些课程的最佳方式,我将非常感激。
大!非常感谢您的回复!我非常感谢你的帮助。自从我在大约8小时前完成我的办公室工作以后,我可能只能在家用电脑上试试看。 – Jonathan
Thakns很多拉斐尔!这工作! – Jonathan