Controller
$data = $this->request->data;
$entities = $table->newEntities($data[‘configuration’]);
debug($entities);
exit();
if ($table->saveMany($entities)) {
$this->Flash->success(__('The configuration has been saved.'));
return $this->redirect(['action' => 'prefix', $prefix]);
}else {
$this->Flash->error(__('The configuration could not be saved. Please, try again.'));
}
Output:-
\src\Controller\Admin\ConfigurationsController.php (line 84)
[
(int) 0 => object(App\Model\Entity\Configuration) {
'input_type' => 'text',
'name' => 'Social.linkedin',
'value' => '',
'[new]' => true,
'[accessible]' => [
'name' => true,
'value' => true,
'title' => true,
'description' => true,
'input_type' => true,
'editable' => true,
'weight' => true,
'params' => true
],
'[dirty]' => [
'input_type' => true,
'name' => true,
'value' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'configurations'
},
(int) 1 => object(App\Model\Entity\Configuration) {
'input_type' => 'text',
'name' => 'Social.skype',
'value' => 'rajeshbansal23',
'[new]' => true,
'[accessible]' => [
'name' => true,
'value' => true,
'title' => true,
'description' => true,
'input_type' => true,
'editable' => true,
'weight' => true,
'params' => true
],
'[dirty]' => [
'input_type' => true,
'name' => true,
'value' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'configurations'
},
(int) 2 => object(App\Model\Entity\Configuration) {
'input_type' => 'text',
'name' => 'Social.googleplus',
'value' => 'https://entities.com',
'[new]' => true,
'[accessible]' => [
'name' => true,
'value' => true,
'title' => true,
'description' => true,
'input_type' => true,
'editable' => true,
'weight' => true,
'params' => true
],
'[dirty]' => [
'input_type' => true,
'name' => true,
'value' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'configurations'
},
(int) 3 => object(App\Model\Entity\Configuration) {
'input_type' => 'text',
'name' => 'Social.facebook',
'value' => 'https://www.facebook.com/theweblogic',
'[new]' => true,
'[accessible]' => [
'name' => true,
'value' => true,
'title' => true,
'description' => true,
'input_type' => true,
'editable' => true,
'weight' => true,
'params' => true
],
'[dirty]' => [
'input_type' => true,
'name' => true,
'value' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'configurations'
},
(int) 4 => object(App\Model\Entity\Configuration) {
'input_type' => 'text',
'name' => 'Social.twitter',
'value' => 'https://twitter.com/rajeshbansal4u',
'[new]' => true,
'[accessible]' => [
'name' => true,
'value' => true,
'title' => true,
'description' => true,
'input_type' => true,
'editable' => true,
'weight' => true,
'params' => true
],
'[dirty]' => [
'input_type' => true,
'name' => true,
'value' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'configurations'
}
]
Error:-
Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘Social.linkedin’ for key ‘key’