Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
fixup! discount percentage for specific customer is implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Brtáň committed Jan 10, 2019
1 parent aafb9ad commit ce7904a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$builderSystemDataGroup->add('discount', IntegerType::class, [
'constraints' => [
new Constraints\NotBlank([
'message' => 'Please enter discount percentage',
]),
new Constraints\Range([
'min' => 0,
'max' => 100,
Expand All @@ -37,7 +40,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]),
],
'label' => t('Discount'),
'required' => false,
]);

if ($options['user'] !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Version20190108205209 extends AbstractMigration
*/
public function up(Schema $schema)
{
$this->sql('ALTER TABLE users ADD discount INT DEFAULT NULL');
$this->sql('ALTER TABLE users ADD discount INT DEFAULT 0 NOT NULL');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Shopsys/ShopBundle/Model/Customer/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User extends BaseUser

/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
* @ORM\Column(type="integer", options={"default" : 0})
*/
protected $discount;

Expand Down

0 comments on commit ce7904a

Please sign in to comment.