diff --git a/src/app/shipping/controllers/ShippingController.php b/src/app/shipping/controllers/ShippingController.php index 24996a6e66db212f8ae35d937333f0c2ab84b5f6..a955227f9f41a06c9b7b1b41e99773027b714d98 100755 --- a/src/app/shipping/controllers/ShippingController.php +++ b/src/app/shipping/controllers/ShippingController.php @@ -104,7 +104,15 @@ class ShippingController $body['fee'] = json_encode($body['fee']); $body['entities'] = json_encode($body['entities']); $body['account'] = json_encode($body['account']); - $id = ShippingModel::create($body); + + $id = ShippingModel::create([ + 'label' => $body['label'], + 'description' => $body['description'], + 'options' => $body['options'], + 'fee' => $body['fee'], + 'entities' => $body['entities'], + 'account' => $body['account'] + ]); HistoryController::add([ 'tableName' => 'shipping_templates', diff --git a/src/app/shipping/models/ShippingModelAbstract.php b/src/app/shipping/models/ShippingModelAbstract.php index 0b088a77efc75be67891f092fd46463f8c6954de..ff6c4cb1493fcc81b835494a22013ab1a69912c9 100755 --- a/src/app/shipping/models/ShippingModelAbstract.php +++ b/src/app/shipping/models/ShippingModelAbstract.php @@ -58,12 +58,22 @@ abstract class ShippingModelAbstract public static function create(array $aArgs) { + ValidatorModel::notEmpty($aArgs, ['label', 'description']); + ValidatorModel::stringType($aArgs, ['label', 'description', 'options', 'fee', 'entities', 'account']); + $nextSequenceId = DatabaseModel::getNextSequenceValue(['sequenceId' => 'shipping_templates_id_seq']); - $aArgs['id'] = $nextSequenceId; DatabaseModel::insert([ 'table' => 'shipping_templates', - 'columnsValues' => $aArgs + 'columnsValues' => [ + 'id' => $nextSequenceId, + 'label' => $aArgs['label'], + 'description' => $aArgs['description'], + 'options' => $aArgs['options'], + 'fee' => $aArgs['fee'], + 'entities' => $aArgs['entities'], + 'account' => $aArgs['account'] + ] ]); return $nextSequenceId; @@ -71,8 +81,9 @@ abstract class ShippingModelAbstract public static function update(array $aArgs) { - ValidatorModel::notEmpty($aArgs, ['id']); + ValidatorModel::notEmpty($aArgs, ['id', 'label', 'description']); ValidatorModel::intVal($aArgs, ['id']); + ValidatorModel::stringType($aArgs, ['label', 'description', 'options', 'fee', 'entities', 'account']); DatabaseModel::update([ 'table' => 'shipping_templates',