我正在研究 Laravel 并在 php artisan 中工作,但我不斷收到此錯誤:用消息'SQLSTATE [23000]照亮/數據庫/查詢異常:完整性約束違規:19 NOT NULL約束失?。簆rofiles.url(SQL:插入“profiles”(“title”,“description”,“user_id”,“updated_at” , "created_at") 值 (Cool, Desc, 1, 2020-03-12 02:03:16, 2020-03-12 02:03:16))'我正在將配置文件附加到用戶,并且我的用戶表包含以下內容:>> User::all()=> Illuminate\Database\Eloquent\Collection {#2992 all: [ App\User {#2993 id: "1", name: "Test User1", email: "[email protected]", username: "test1", email_verified_at: null, created_at: "2020-03-12 02:01:08", updated_at: "2020-03-12 02:01:08", }, ], }這是我在 PHP Artisan 中輸入的>>> $profile = new \App\Profile();=> App\Profile {#2987}>>> $profile->title = 'Cool Title';=> "Cool Title">>> $profile->description = 'Desc';=> "Desc">>> $profile->user_id = 1;=> 1>>> $profile->save();Profiles_table.phpclass CreateProfilesTable extends Migration{ /** * Run the migrations. * * @return void */ public function up() { Schema::create('profiles', function (Blueprint $table) { $table->bigIncrements('id')->nullable; $table->unsignedBigInteger('user_id')->nullable; $table->string('title')->nullable; $table->text('description')->nullable; $table->string('url')->nullable; $table->timestamps(); $table->index('user_id'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('profiles'); }}我找不到失敗的原因。希望有人能找出是什么原因造成的。謝謝
1 回答

慕的地10843
TA貢獻1785條經驗 獲得超8個贊
我認為您的“個人資料”遷移有誤。
$table->string('url')->nullable;
至
$table->string('url')->nullable();
- 1 回答
- 0 關注
- 61 瀏覽
添加回答
舉報
0/150
提交
取消