Skip to content

Commit fbf0500

Browse files
committed
feat: create new property on address to defined if the address was picked via the map
1 parent a77ccbe commit fbf0500

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Application\Migrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250505131027 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE address ADD is_map_picked BOOLEAN NOT NULL DEFAULT FALSE');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE address DROP is_map_picked');
30+
}
31+
}

src/Controller/ArgumentResolver/AddressValueResolver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function resolve(Request $request, ArgumentMetadata $argument)
7474
$address->setGeo(new GeoCoordinates($latitude, $longitude));
7575
}
7676

77+
if (isset($data['isMapPicked']) && $data['isMapPicked']) {
78+
$address->setIsMapPicked(true);
79+
}
80+
7781
return yield $address;
7882
}
7983

src/Entity/Address.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class Address extends BaseAddress
2828

2929
private $complete;
3030

31+
32+
private bool $isMapPicked = false;
33+
3134
/**
3235
* Gets id.
3336
*
@@ -130,6 +133,18 @@ public function getComplete(): bool
130133
return $this->complete;
131134
}
132135

136+
137+
#[Groups(['address', 'address_create', 'task', 'task_create', 'task_edit', 'order_update', 'restaurant_delivery'])]
138+
public function getIsMapPicked(): bool
139+
{
140+
return $this->isMapPicked;
141+
}
142+
143+
public function setIsMapPicked(bool $isMapPicked)
144+
{
145+
$this->isMapPicked = $isMapPicked;
146+
}
147+
133148
public function clone()
134149
{
135150
$address = new Address();
@@ -146,6 +161,7 @@ public function clone()
146161
$address->setTelephone($this->telephone);
147162
$address->setName($this->getName());
148163
$address->setPostalCode($this->postalCode);
164+
$address->setIsMapPicked($this->isMapPicked);
149165

150166
return $address;
151167
}

src/Resources/config/doctrine/Address.orm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<field name="company" type="string" column="company" nullable="true"/>
2424
<field name="telephone" type="phone_number" column="telephone" nullable="true"/>
2525
<field name="contactName" type="string" column="contact_name" nullable="true"/>
26+
<field name="isMapPicked" type="boolean" column="is_map_picked" />
2627
<entity-listeners>
2728
<entity-listener class="AppBundle\Entity\Listener\AddressListener">
2829
<lifecycle-callback type="preUpdate" method="preUpdate"/>

0 commit comments

Comments
 (0)