add Moderation.php (#14)
Co-authored-by: bastien <bastien.ollier1@gmail.com> Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr> Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/14 Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr>
This commit is contained in:
@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\PostRepository;
|
||||
use App\Validator\ImageSafety;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
@@ -64,6 +65,7 @@ class Post
|
||||
|
||||
#[Vich\UploadableField(mapping: 'posts', fileNameProperty: 'image')]
|
||||
#[Assert\Image]
|
||||
#[ImageSafety]
|
||||
private ?File $imageFile = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
@@ -184,6 +186,9 @@ class Post
|
||||
public function setImageFile(?File $imageFile): static
|
||||
{
|
||||
$this->imageFile = $imageFile;
|
||||
if ($imageFile !== null) {
|
||||
$this->updatedAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user