mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 20:44:03 +00:00
8a28eb1790
This reverts merge request !5
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Accounts\Validation;
|
|
|
|
|
|
use App\Classes\Modules\Accounts\DataTransferObjects\UserInvitationObject;
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\ResourceConflictException;
|
|
use App\Models\UserInvitation;
|
|
|
|
class InvitationAlreadyExists
|
|
{
|
|
|
|
/** @var UserInvitation */
|
|
private $repository;
|
|
|
|
/**
|
|
* CreatesUserInvitation constructor.
|
|
* @param UserInvitation $repository
|
|
*/
|
|
public function __construct(UserInvitation $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
/**
|
|
* @param UserInvitationObject $object
|
|
* @return bool
|
|
* @throws ResourceConflictException
|
|
*/
|
|
public function execute(UserInvitationObject $object){
|
|
|
|
// ensure that there is not already an invitation for the email
|
|
$existingInvitations = $this->repository->where('email', $object->getInviteeEmail())->first();
|
|
|
|
if ($existingInvitations) {
|
|
throw new ResourceConflictException("An existing invitation already exists for the email {$object->getInviteeEmail()}");
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
} |