我正在進行遷移,我希望某些字段不能爲空。爲了方便起見,我將使用Laravel附帶的用戶遷移作爲示例。Eloquent在非空字段中保存沒有值
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
無其田是nullables但如果我做:
$user = new User();
$user->save();
User::all();
它返回
Illuminate\Database\Eloquent\Collection {#639
all: [
App\User {#640
id: "1",
name: "",
email: "",
created_at: "2016-06-29 15:51:01",
updated_at: "2016-06-29 15:51:01",
},
],
}
在哪裏)可空點(修正,如果我能救記錄,而不數據在非空字段?