Open
Description
I'm using the latest backpack version with pro addon, this is my field:
CRUD::addField([
'name' => 'users',
'type' => 'relationship',
'label' => __('backend/dealership.managers'),
'model' => 'App\Models\User',
'attribute' => 'fullName',
'pivot' => false,
'inline_create' => ['entity' => 'user'],
'data_source' => route('dealership.fetchEdpUsers'),
'minimum_input_length' => 0
]);
essentially a dealership can have many users, but a user can only have one dealership.
This is the relationship on Dealership model:
public function users() {
return $this->hasMany(User::class);
}
and this is the relationship on User model:
public function dealership()
{
return $this->belongsTo(Dealership::class);
}
When I save the users on the Dealership controller everything works fine, but when I remove one user from the repeatable and then save I get:
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'NULL' for column razor
.users
.dealership_id
at row 1 (Connection: mysql, SQL: update users
set dealership_id
= NULL, users
.updated_at
= 2025-02-20 12:42:47 where id
not in (5) and dealership_id
= 1)
The column dealership_id is set to nullable on the users table, I don't understand
Field | Type | Null | Key | Default | Extra | |
---|---|---|---|---|---|---|
id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | |
first_name | varchar(255) | YES | NULL | |||
last_name | varchar(255) | YES | NULL | |||
business_name | varchar(255) | YES | NULL | |||
varchar(255) | NO | UNI | NULL | |||
dealership_id | bigint(20) unsigned | YES | MUL | NULL | ||
email_verified_at | timestamp | YES | NULL | |||
password | varchar(255) | NO | NULL | |||
remember_token | varchar(100) | YES | NULL | |||
created_at | timestamp | YES | NULL | |||
updated_at | timestamp | YES | NULL |
Metadata
Metadata
Assignees
Type
Projects
Status
No status