Skip to content

Commit a4a316a

Browse files
committed
Make blog post titles unique
1 parent 52ef1b7 commit a4a316a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Entity/Post.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
use Doctrine\Common\Collections\ArrayCollection;
1515
use Doctrine\Common\Collections\Collection;
1616
use Doctrine\ORM\Mapping as ORM;
17+
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
1718
use Symfony\Component\Validator\Constraints as Assert;
1819

1920
/**
2021
* @ORM\Entity(repositoryClass="App\Repository\PostRepository")
2122
* @ORM\Table(name="symfony_demo_post")
23+
* @UniqueEntity(fields={"slug"}, errorPath="title")
2224
*
2325
* Defines the properties of the Post entity to represent the blog posts.
2426
*

0 commit comments

Comments
 (0)