當 php artisan migrate
出現以下狀況時:
In Macroable.php line 74:
Method id does not exist.
如果是原始建立的專案會有create_users_table以及create_password_resets_table作為範本
create_users_table檔案需要更改如以下
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
**$table->increments('id');**原本為$table->ip() 現行版本不支援
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
//
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
//
}
}
如果新增檔案後想要刪除檔案
還沒php artisan migrate
1.刪除建立的檔案
2.composer dump-autoload
如果已經執行 php artisan migrate
php artisan migrate:refresh
composer dump-autoload
刪除database 裡的table