diff --git a/src/ApiResource/User/UserApiResource.php b/src/ApiResource/User/UserApiResource.php index 5d60285..46543ea 100644 --- a/src/ApiResource/User/UserApiResource.php +++ b/src/ApiResource/User/UserApiResource.php @@ -7,6 +7,7 @@ use ApiPlatform\Metadata as API; use App\ApiResource\Accounting\AccountingApiResource; use App\Dto\UserSignupDto; use App\Entity\User\User; +use App\Entity\User\UserType; use App\Filter\OrderedLikeFilter; use App\Filter\UserQueryFilter; use App\State\ApiResourceStateProcessor; @@ -47,6 +48,29 @@ class UserApiResource #[Assert\Regex('/^[a-z0-9_]+$/')] public string $handle; + /** + * URL to the avatar image of this User. + */ + #[Assert\Url()] + public string $avatar; + + /** + * Is this User for an individual acting on their own or a group of individuals? + */ + #[API\ApiProperty(securityPostDenormalize: 'is_granted("USER_EDIT")')] + public UserType $type; + + /** + * A list of the roles assigned to this User. Admin scoped property. + * + * @var array + */ + #[API\ApiProperty( + security: 'is_granted("ROLE_ADMIN")', + securityPostDenormalize: 'is_granted("ROLE_ADMIN")' + )] + public array $roles; + /** * The Accounting for this User monetary movements. */ @@ -61,17 +85,6 @@ class UserApiResource #[API\ApiProperty(writable: false)] public array $projects; - /** - * A list of the roles assigned to this User. Admin scoped property. - * - * @var array - */ - #[API\ApiProperty( - security: 'is_granted("ROLE_ADMIN")', - securityPostDenormalize: 'is_granted("ROLE_ADMIN")' - )] - public array $roles; - /** * Has this User confirmed their email address? */ @@ -81,5 +94,6 @@ class UserApiResource /** * A flag determined by the platform for Users who are known to be active. */ + #[API\ApiProperty(writable: false)] public bool $active; } diff --git a/src/Entity/User/User.php b/src/Entity/User/User.php index 53d2d76..fd31e08 100644 --- a/src/Entity/User/User.php +++ b/src/Entity/User/User.php @@ -13,6 +13,7 @@ use App\Repository\User\UserRepository; use AutoMapper\Attribute\MapProvider; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; @@ -95,6 +96,18 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account #[ORM\OneToOne(mappedBy: 'user', cascade: ['persist', 'remove'])] private ?UserPersonal $personalData = null; + /** + * Is this user for an individual acting on their own or a larger group of individuals? + */ + #[ORM\Column(enumType: UserType::class)] + private ?UserType $type = null; + + /** + * URL to the avatar image of this User. + */ + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $avatar = null; + public function __construct() { $this->accounting = Accounting::of($this); @@ -306,4 +319,28 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, Account return $this; } + + public function getType(): ?UserType + { + return $this->type; + } + + public function setType(UserType $type): static + { + $this->type = $type; + + return $this; + } + + public function getAvatar(): ?string + { + return $this->avatar; + } + + public function setAvatar(?string $avatar): static + { + $this->avatar = $avatar; + + return $this; + } } diff --git a/src/Entity/User/UserType.php b/src/Entity/User/UserType.php new file mode 100644 index 0000000..adb8f8f --- /dev/null +++ b/src/Entity/User/UserType.php @@ -0,0 +1,16 @@ +