SupplierSchemasTable
$this->hasMany('SupplierSchemaItems'); $this->belongsToMany('Suppliers'); +----+----------+ | id | title | +----+----------+ | 1 | schema_1 | | 2 | schema_2 | +----+----------+ SuppliersTable
$this->belongsToMany('SupplierSchemas'); $this->belongsToMany('SupplierSchemaItems', [ 'through' => 'SupplierSchemaItemsSuppliers', ]); +----+------------+ | id | name | +----+------------+ | 1 | supplier_1 | +----+------------+ SupplierSchemasInputTypesTable
$this->hasMany('SupplierSchemaItems'); +----+----------+ | id | title | +----+----------+ | 1 | Text | | 2 | Textarea | | 3 | Select | +----+----------+ SupplierSchemaItemsTable
$this->belongsTo('SupplierSchemas'); $this->belongsToMany('Suppliers', [ 'through' => 'SupplierSchemaItemsSuppliers', ]); +----+--------------------------+--------------------+--------------------------------+ | id | title | supplier_schema_id | supplier_schemas_input_type_id | +----+--------------------------+--------------------+--------------------------------+ | 1 | Partners | 1 | 1 | | 2 | Bio | 1 | 2 | | 3 | Identification Documents | 1 | 3 | +----+--------------------------+--------------------+--------------------------------+ SupplierSchemaItemsSuppliersTable
$this->belongsTo('SupplierSchemasInputTypes'); $this->belongsTo('SupplierSchemaItems'); $this->belongsTo('Suppliers'); +----+-------------------------+-------------+-------------------------+ | id | supplier_schema_item_id | supplier_id | value | +----+-------------------------+-------------+-------------------------+ | 1 | 1 | 1 | 4 | | 2 | 2 | 1 | Supplier Bio Text | | 3 | 3 | 1 | Current Signed Passport | | 4 | 3 | 1 | Driving Licence | +----+-------------------------+-------------+-------------------------+ I need to allow admin to be able to update data in SupplierSchemaItemsSuppliersTable. However when I try to do so using below
$SuppliersTable->patchEntity($supplier, $this->request->data(), [ 'associated' => [ 'SupplierSchemas.SupplierSchemaItems.Suppliers', ] ]); It works for rows where both supplier_schema_item_id and supplier_id is different. However for the select ( Identification Documents ) which can have more than one item it fails i.e. will only update the first record and delete the second one.
Below is the Data Dump for the request data:
[ (int) 0 => [ 'id' => '1', 'supplier_schema_items' => [ (int) 2 => [ 'id' => '3', 'suppliers' => [ (int) 0 => [ 'id' => '1', '_joinData' => [ 'id' => '3', 'value' => 'Current Signed Passport - Edit Test' ] ], (int) 1 => [ 'id' => '1', '_joinData' => [ 'id' => '4', 'value' => 'Driving Licesnce - Edit Test 2' ] ] ] ] ] ] ]
0 comments:
Post a Comment