mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-19 04:14:05 +00:00
49 lines
1.2 KiB
PHP
Executable File
49 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Classes\Modules\Accounts\Services;
|
|
|
|
|
|
use App\Classes\common;
|
|
use App\Classes\Modules\Accounts\DataTransferObjects\UserInvitationObject;
|
|
use App\Classes\Modules\Accounts\Exceptions\InvitationAlreadyExistsException;
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\ResourceConflictException;
|
|
use App\Models\UserInvitation;
|
|
|
|
final class CreatesUserInvitation
|
|
{
|
|
|
|
/** @var UserInvitation */
|
|
private $repository;
|
|
|
|
/**
|
|
* CreatesUserInvitation constructor.
|
|
* @param UserInvitation $repository
|
|
*/
|
|
public function __construct(UserInvitation $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param UserInvitationObject $object
|
|
* @return UserInvitation|null
|
|
* @throws ResourceConflictException
|
|
*/
|
|
public function execute(UserInvitationObject $object): ?UserInvitation {
|
|
|
|
|
|
|
|
$this->repository->email = $object->getInviteeEmail();
|
|
$this->repository->hash = $object->getHash();
|
|
$this->repository->role_id = $object->getRole();
|
|
$this->repository->sender_id = auth()->user()->getAuthIdentifier();
|
|
$this->repository->is_complete = false;
|
|
|
|
$this->repository->save();
|
|
|
|
return $this->repository;
|
|
|
|
}
|
|
|
|
} |