#97: add emojis to foodvendor
This commit is contained in:
parent
e2167fa19f
commit
c8e6af6896
7 changed files with 176 additions and 4 deletions
|
@ -7,23 +7,27 @@ use App\Repository\FoodVendorRepository;
|
|||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Uid\Ulid;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use function mb_strlen;
|
||||
|
||||
#[ORM\Entity(repositoryClass: FoodVendorRepository::class)]
|
||||
#[ApiResource]
|
||||
class FoodVendor
|
||||
{
|
||||
#[ORM\Column(length: 50)]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true, options: [
|
||||
'default' => '',
|
||||
])]
|
||||
#[Groups(['food_order:latest'])]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
private string|null $phone = null;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +46,14 @@ class FoodVendor
|
|||
#[Groups(['food_order:latest'])]
|
||||
private string|null $menuLink = null;
|
||||
|
||||
/**
|
||||
* String of emojis (max 30 characters)
|
||||
*/
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
#[Groups(['food_order:latest', 'food_vendor:read'])]
|
||||
#[Length(max: 10)]
|
||||
private string|null $emojis = null;
|
||||
|
||||
public function __construct(
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
|
@ -155,4 +167,19 @@ class FoodVendor
|
|||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmojis(): string|null
|
||||
{
|
||||
return $this->emojis;
|
||||
}
|
||||
|
||||
public function setEmojis(string|null $emojis): static
|
||||
{
|
||||
if ($emojis !== null && mb_strlen($emojis) > 30) {
|
||||
throw new InvalidArgumentException('A maximum of 30 characters is allowed for emojis');
|
||||
}
|
||||
|
||||
$this->emojis = $emojis;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue