Complete profile image, password update functionality
This commit is contained in:
parent
8d97ab0345
commit
ea322dc2ac
@ -12,6 +12,7 @@ use App\Form\UserFormType;
|
||||
use App\Libs\Breadcrumb;
|
||||
use App\Libs\NavList;
|
||||
use App\Repository\UserRepository;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@ -145,6 +146,7 @@ class AdminController extends AbstractController
|
||||
->setRate($form->get('rate')->getData())
|
||||
->setLevel($form->get('level')->getData())
|
||||
->setCompany($admin->getCompany())
|
||||
->setPasswordChanged(new DateTime())
|
||||
;
|
||||
|
||||
if ($form->get('imageName')->getData()) {
|
||||
|
@ -6,6 +6,7 @@ use App\Entity\Messages;
|
||||
use App\Entity\User;
|
||||
use App\Libs\Breadcrumb;
|
||||
use App\Libs\NavList;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
@ -135,6 +136,7 @@ class DefaultController extends AbstractController
|
||||
$plainPassword
|
||||
)
|
||||
);
|
||||
$user->setPasswordChanged(new DateTime())
|
||||
}
|
||||
|
||||
if ($form['imageName']->getData()) {
|
||||
|
@ -14,10 +14,13 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Vich\UploaderBundle\Entity\File;
|
||||
use Vich\UploaderBundle\Mapping\Annotation as Vich;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_USERNAME', fields: ['username'])]
|
||||
#[UniqueEntity(fields: ['username'], message: 'There is already an account with this username')]
|
||||
#[Vich\Uploadable]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
@ -80,6 +83,15 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\OneToMany(targetEntity: UserCase::class, mappedBy: 'user')]
|
||||
private Collection $userCases;
|
||||
|
||||
#[Vich\UploadableField(mapping: 'profile_image', fileNameProperty: 'imageName', size: 'size', mimeType: 'mimeType', originalName: 'originalName', dimensions: 'dimensions')]
|
||||
private ?File $imageFile = null;
|
||||
|
||||
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
|
||||
private ?string $imageName = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $passwordChanged = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->userCases = new ArrayCollection();
|
||||
@ -351,4 +363,40 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
public function getImageFile(): ?File
|
||||
{
|
||||
return $this->imageFile;
|
||||
}
|
||||
|
||||
public function setImageFile(?File $imageFile): static
|
||||
{
|
||||
$this->imageFile = $imageFile;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getImageName(): ?string
|
||||
{
|
||||
return $this->imageName;
|
||||
}
|
||||
|
||||
public function setImageName(?string $imageName): static
|
||||
{
|
||||
$this->imageName = $imageName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPasswordChanged(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->passwordChanged;
|
||||
}
|
||||
|
||||
public function setPasswordChanged(\DateTimeInterface $passwordChanged): static
|
||||
{
|
||||
$this->passwordChanged = $passwordChanged;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user