laravel - 如何使用迁移在没有 created_at 和 Updated_at 列的 laravel 中创建表
问题描述
任何人都可以知道如何在 laravel 中创建表,而无需使用迁移表中的 created_at 和 Updated_at 列。我尝试以下代码,但它仍然在表中创建 created_at 和 Updated_at 列:-
迁移 Laravel:-
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNewusersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('newusers', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('name');
$table->string('email', 100)->unique();
$table->bigInteger('phone_no');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('newusers');
}
}
解决方案
将此添加到您的模型中
public $timestamps = false;
推荐阅读
- java - 如何显示两个或多个复选框的值
- c++ - 有人可以分解这个 c++ 模板的语法吗?
- javascript - 为什么这个形状不填充()?
- javascript - 如何在传单js中使用矩形传递数据
- json - 如何将 json 解组为 Go 结构映射?
- postgresql - 每组动态交叉加入
- python - 如何在不使用 eval() 的情况下将字符串的用户输入评估为数学表达式?
- java - 防病毒程序(如 Windows Defender)会在运行较大的 Java 程序时导致内存错误吗?
- java - Java API 调用将根据队列大小进行合并或在最旧项目插入队列后 4 秒内执行
- javascript - 访问 webpack 配置文件中的浏览器窗口对象