[英]Laravel Voyager SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value
I'm using voyager as admin panel in my backend getting this type of error while creating BREAD 我在后台使用voyager作为管理面板,在创建BREAD时遇到此类错误
SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL:
insert into `data_types` (`name`, `display_name_singular`, `display_name_plural`,
`slug`, `icon`, `model_name`, `controller`, `policy_name`, `generate_permissions`,
`details`, `description`, `server_side`, `updated_at`, `created_at`) values (hdept,
Hdept, Hdepts, hdept, , App\Hdept, , , 1, {"order_column":null, "order_display_column":null,
"order_direction":"asc", "default_search_key":null}, , 0, 2019-03-04 12:56:29,
2019-03-04 12:56:29))
model (Hdept.php) 模型(Hdept.php)
namespace App;
use Illuminate\Database\Eloquent\Model;
class Hdept extends Model
{
protected $fillables = [ 'id'];
}
This simply means you need to specify the value for id
when you insert a new record or you need to provide a default value in your table definition. 这只是意味着您在插入新记录时需要指定
id
的值,或者需要在表定义中提供默认值。
You could define an auto-incrementing id in your migration: 您可以在迁移中定义一个自动递增的ID:
$table->increments('id');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.