Php 为什么Laravel数据库工厂不插入主键值?
使用factory将customer_id插入customer表时,它不会插入值。cutomer_id是表的主键 模型 在测试课上Php 为什么Laravel数据库工厂不插入主键值?,php,laravel,Php,Laravel,使用factory将customer_id插入customer表时,它不会插入值。cutomer_id是表的主键 模型 在测试课上 $customer = factory(Customer::class)->create([ 'customer_id' => 1111 ]); 如果主键不是默认的“id”,并且如果需要插入客户值,则应添加$incrementing=false protected $primaryKey = 'customer_id';
$customer = factory(Customer::class)->create([
'customer_id' => 1111
]);
如果主键不是默认的“id”,并且如果需要插入客户值,则应添加$incrementing=false
protected $primaryKey = 'customer_id';
public $incrementing = false;
protected $primaryKey = 'customer_id';
public $incrementing = false;