Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel中的第一列之前添加新列?_Php_Laravel_Laravel Migrations - Fatal编程技术网

Php 如何在laravel中的第一列之前添加新列?

Php 如何在laravel中的第一列之前添加新列?,php,laravel,laravel-migrations,Php,Laravel,Laravel Migrations,我首先需要使用laravel迁移在Sql中添加一列。我可以使用以下命令在任意位置添加新列: Schema::table('tasks', function (Blueprint $table) { if (Schema::hasColumn('tasks', 'assigned_to_id') == false) { $table->integer('assigned_to_id')->after('status');

我首先需要使用laravel迁移在Sql中添加一列。我可以使用以下命令在任意位置添加新列:

  Schema::table('tasks', function (Blueprint $table) {
        if (Schema::hasColumn('tasks', 'assigned_to_id') == false) {
                $table->integer('assigned_to_id')->after('status');
        }
  });
表包含以下字段: 项目id,模块id

我需要在项目id之前添加列“id”。 如何做到这一点?
提前谢谢

您可以使用$table->integer'id'->首先添加id作为第一列

您可以使用$table->integer'id'->首先添加id作为第一列

谢谢@Hasta Dhana!谢谢@Hasta Dhana!你能试试看用两次是否有效吗?你能试试看用两次是否有效吗?