mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0bbf0f9138 | |||
| 2c39c66a2d | |||
| a56b5c64ba | |||
| 86401cdad6 | |||
| 558868d859 | |||
| 149029bc24 | |||
| ab84ca4719 | |||
| 6a4e2926b9 |
@@ -51,5 +51,3 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HasPendingDelivery implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $value ? $builder->whereHas('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
}) : $builder->whereDoesntHave('packingLists', function (Builder $query) use($value) {
|
||||
$query->whereDoesntHave('transports');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListStatus implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.status', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PackingListType implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('packing_lists.type', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithArrivalDate implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->leftJoin('transport_arrangements', function ($join) {
|
||||
$join->on('packing_lists.id', '=', 'transport_arrangements.owner_id')->where('transport_arrangements.owner_type', 'App\Models\PackingList');
|
||||
})->addSelect(['packing_lists.*', DB::raw('transport_arrangements.drop_date as arrival_date')]);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
interface Packable
|
||||
{
|
||||
|
||||
public function packingLists(): morphMany;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceConflictException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Accounts\Processors\GenerateEmailVerificationAttemptProcessor;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AddNewMemberLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
public function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated Email',
|
||||
'message' => 'Successfully updated email'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @var AssignEmployeeProcessor
|
||||
*/
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/**
|
||||
* @var GenerateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
private $generateEmailVerificationAttemptProcessor;
|
||||
|
||||
/**
|
||||
* AddNewMemberLogic constructor.
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
*/
|
||||
public function __construct(AssignEmployeeProcessor $assignEmployeeProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor)
|
||||
{
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ResourceConflictException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$user = Auth::user()->replicate();
|
||||
$user->email = $request->input('email');
|
||||
$user->status = ApprovalStatus::PENDING_VERIFICATION;
|
||||
$user->save();
|
||||
} catch (QueryException $exception){
|
||||
throw new ResourceConflictException('Unable to change your email address as it already exists');
|
||||
}
|
||||
|
||||
if($company = Auth::user()->companyModule()->first()){
|
||||
$Object = new EmploymentObject($company, $user);
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
}
|
||||
|
||||
$this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
return $this->resourceResponse(new UserResource($user));
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CrossAuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CrossAuthenticateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Cross Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CrossAuthenticationProcessor */
|
||||
private $crossAuthenticationProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CrossAuthenticateUserLogic constructor.
|
||||
* @param CrossAuthenticationProcessor $authenticationProcessor
|
||||
*/
|
||||
public function __construct(CrossAuthenticationProcessor $crossAuthenticationProcessor)
|
||||
{
|
||||
$this->crossAuthenticationProcessor = $crossAuthenticationProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
return $this->response($this->crossAuthenticationProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class LogoutUserLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function __construct(InvalidatesAuthenticationToken $invalidatesAuthenticationToken)
|
||||
{
|
||||
logger("logout user logic");
|
||||
$this->invalidatesAuthenticationToken = $invalidatesAuthenticationToken;
|
||||
}
|
||||
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class CrossAuthenticationCredentialsObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $access_token;
|
||||
|
||||
/** @var string */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationCredentialsObject constructor.
|
||||
* @param string $access_token
|
||||
* @param string $platform
|
||||
*/
|
||||
public function __construct(string $access_token, int $platform)
|
||||
{
|
||||
$this->access_token = $access_token;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessToken(): string
|
||||
{
|
||||
return $this->access_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Models\User;
|
||||
|
||||
class UserSocialAccountObject implements DataTransferObject
|
||||
{
|
||||
/** @var String */
|
||||
private $app_id;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var integer */
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* UserSocialAccountObject constructor.
|
||||
* @param String $token
|
||||
* @param String $app_id
|
||||
*/
|
||||
public function __construct(String $app_id, User $user, int $platform)
|
||||
{
|
||||
$this->app_id = $app_id;
|
||||
$this->user = $user;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAppId(): String
|
||||
{
|
||||
return $this->app_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPlatform(): int
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmploymentObject;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\CrossAuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCrossAuthenticateUser;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\CreateUserProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyModuleProcessor;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\General\Services\GeneratesInitials;
|
||||
use App\Classes\Modules\Companies\Services\ApprovesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Processors\AssignEmployeeProcessor;
|
||||
use App\Classes\Modules\Documents\Processors\UploadIdentityDocumentProcessor;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUserSocialAccount;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CrossAuthenticationProcessor
|
||||
{
|
||||
|
||||
/** @var CanCrossAuthenticateUser */
|
||||
private $canCrossAuthenticateUser;
|
||||
|
||||
/** @var CrossAuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var CreateUserProcessor */
|
||||
private $createUserProcessor;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var CreateCompanyModuleProcessor */
|
||||
private $createCompanyModuleProcessor;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
|
||||
/** @var ApprovesCompanyConnection */
|
||||
private $approvesCompanyConnection;
|
||||
|
||||
/** @var AssignEmployeeProcessor */
|
||||
private $assignEmployeeProcessor;
|
||||
|
||||
/** @var UploadIdentityDocumentProcessor */
|
||||
private $uploadIdentityDocumentProcessor;
|
||||
|
||||
/** @var CreatesUserSocialAccount */
|
||||
private $createsUserSocialAccount;
|
||||
|
||||
/**
|
||||
* CrossAuthenticationProcessor constructor.
|
||||
* @param CanCrossAuthenticateUser $canCrossAuthenticateUser
|
||||
* @param CrossAuthenticatesUser $crossAuthenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param CreateCompanyModuleProcessor $createCompanyModuleProcessor
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param ApprovesCompanyConnection $approvesCompanyConnection
|
||||
* @param AssignEmployeeProcessor $assignEmployeeProcessor
|
||||
* @param UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor
|
||||
* @param CreatesUserSocialAccount $createsUserSocialAccount
|
||||
*/
|
||||
public function __construct(
|
||||
CanCrossAuthenticateUser $canCrossAuthenticateUser,
|
||||
CrossAuthenticatesUser $crossAuthenticatesUser,
|
||||
GeneratesAuthenticationToken $generatesAuthenticationToken,
|
||||
FetchesUser $fetchesUser,
|
||||
AuthenticationRedirect $authenticationRedirect,
|
||||
CreateUserProcessor $createUserProcessor,
|
||||
CreateCompanyProcessor $createCompanyProcessor,
|
||||
CreateContactProcessor $createContactProcessor,
|
||||
CreateCompanyModuleProcessor $createCompanyModuleProcessor,
|
||||
CreatesCompanyConnection $createsCompanyConnection,
|
||||
ApprovesCompanyConnection $approvesCompanyConnection,
|
||||
AssignEmployeeProcessor $assignEmployeeProcessor,
|
||||
UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor,
|
||||
CreatesUserSocialAccount $createsUserSocialAccount
|
||||
)
|
||||
{
|
||||
$this->canCrossAuthenticateUser = $canCrossAuthenticateUser;
|
||||
$this->crossAuthenticatesUser = $crossAuthenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
$this->createContactProcessor = $createContactProcessor;
|
||||
$this->createCompanyModuleProcessor = $createCompanyModuleProcessor;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->createsCompanyConnection = $createsCompanyConnection;
|
||||
$this->approvesCompanyConnection = $approvesCompanyConnection;
|
||||
$this->assignEmployeeProcessor = $assignEmployeeProcessor;
|
||||
$this->uploadIdentityDocumentProcessor = $uploadIdentityDocumentProcessor;
|
||||
$this->createsUserSocialAccount = $createsUserSocialAccount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new CrossAuthenticationCredentialsObject($request->input('access_token'), $request->input('platform'));
|
||||
|
||||
$this->canCrossAuthenticateUser->passes($object);
|
||||
|
||||
$cross = $this->crossAuthenticatesUser->execute($object);
|
||||
|
||||
$user_social_account = UserSocialAccount::where('app_id', $cross->token->user->id)->first();
|
||||
if (!$user_social_account) {
|
||||
|
||||
$request->request->add([
|
||||
'name' => $cross->token->user->name,
|
||||
'email' => $cross->token->user->email,
|
||||
'password' => 'pass123',
|
||||
'password_confirmation' => 'pass123',
|
||||
]);
|
||||
|
||||
$user = $this->createUserProcessor->execute(
|
||||
$request,
|
||||
RoleTypes::USER,
|
||||
env('APP_ENV') != 'production' ? ApprovalStatus::APPROVED : ApprovalStatus::PENDING_VERIFICATION
|
||||
);
|
||||
|
||||
$company = $this->createCompanyProcessor->execute(
|
||||
$cross->payload->data->name,
|
||||
CompanyType::COMPANY_BUSINESS,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$contactObject = new ContactObject(
|
||||
$cross->payload->data->contact->reference,
|
||||
$cross->payload->data->contact->phone,
|
||||
$cross->payload->data->contact->email,
|
||||
$cross->payload->data->contact->wechat_id
|
||||
);
|
||||
$contact = $this->createContactProcessor->execute($contactObject, $company);
|
||||
|
||||
$companyModule = $this->createCompanyModuleProcessor->execute($company, BusinessType::IMPORTER);
|
||||
|
||||
$connectionObject = new CompanyConnectionObject(
|
||||
$companyModule, 'CIEF',
|
||||
mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate()
|
||||
);
|
||||
$connection = $this->createsCompanyConnection->execute($connectionObject);
|
||||
|
||||
$this->approvesCompanyConnection->execute($connection);
|
||||
|
||||
$object = new EmploymentObject($companyModule, $user);
|
||||
$this->assignEmployeeProcessor->execute($object);
|
||||
|
||||
$request->request->add([
|
||||
'files' => [$cross->document->src],
|
||||
'identification_no' => $cross->payload->data->identification->reference,
|
||||
]);
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
$object = new UserSocialAccountObject(
|
||||
$cross->token->user->id,
|
||||
$user,
|
||||
$request->input('platform')
|
||||
);
|
||||
$this->createsUserSocialAccount->execute($object);
|
||||
}
|
||||
else {
|
||||
$user = $user_social_account->user()->first();
|
||||
}
|
||||
|
||||
return ['access_token' => $this->generatesAuthenticationToken->execute($user), 'redirect_url' => $this->authenticationRedirect->url($user)];
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -56,4 +56,4 @@ class GenerateEmailVerificationAttemptProcessor
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserSocialAccountObject;
|
||||
use App\Models\UserSocialAccount;
|
||||
|
||||
class CreatesUserSocialAccount extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param UserSocialAccountObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(UserSocialAccountObject $object) {
|
||||
$model = new UserSocialAccount();
|
||||
$model->user_id = $object->getUser()->id;
|
||||
$model->app_id = $object->getAppId();
|
||||
$model->platform = $object->getPlatform();
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
use App\Classes\ValueObjects\Constants\PlatformType;
|
||||
|
||||
class CrossAuthenticatesUser
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return false|string
|
||||
* @throws AccessUnauthorisedException
|
||||
*/
|
||||
|
||||
public function execute(CrossAuthenticationCredentialsObject $object){
|
||||
|
||||
if ($object->getPlatform() == PlatformType::EXCHANGE) {
|
||||
|
||||
$token = $object->getAccessToken();
|
||||
|
||||
$tokenParts = explode(".", $token);
|
||||
$tokenPayload = base64_decode($tokenParts[1]);
|
||||
$jwtPayload = json_decode($tokenPayload);
|
||||
|
||||
$response = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/company/' . $jwtPayload->user->company_id . '/show')->object();
|
||||
|
||||
$response_document = Http::withToken($object->getAccessToken())->get(env('EXCHANGE_URL') . 'api/v1/storage/' . $response->payload->data->identification->files[0]->file->file_info[0]->original->file . '/fetch')->object();
|
||||
$response->token = $jwtPayload;
|
||||
$response->document = $response_document->payload;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Standards\Validators\UserCrossAuthenticationValidation;
|
||||
|
||||
class CanCrossAuthenticateUser extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var UserCrossAuthenticationValidation */
|
||||
private $userCrossAuthenticationValidation;
|
||||
|
||||
/**
|
||||
* CanCrossAuthenticateUser constructor.
|
||||
* @param UserCrossAuthenticationValidation $userCrossAuthenticationValidation
|
||||
*/
|
||||
public function __construct(UserCrossAuthenticationValidation $userCrossAuthenticationValidation)
|
||||
{
|
||||
$this->userCrossAuthenticationValidation = $userCrossAuthenticationValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->userCrossAuthenticationValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\CrossAuthenticationCredentialsObject;
|
||||
|
||||
class UserCrossAuthenticationValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param CrossAuthenticationCredentialsObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'access_token' => $object->getAccesstoken(),
|
||||
'platform' => $object->getPlatform()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'access_token' => 'required',
|
||||
'platform' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignAnnouncementToSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Assign Announcement To Segment',
|
||||
'message' => 'You have successfully assigned Announcement to segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnouncement, AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor)
|
||||
{
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$announcement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanCreateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\CreatesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Processors\AssignAnnouncementToSegmentProcessor;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created Annoucement',
|
||||
'message' => 'You have successfully created a new Annoucements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateAnnouncement */
|
||||
private $canCreateAnnouncement;
|
||||
|
||||
/** @var CreatesAnnoucement */
|
||||
private $createsAnnoucement;
|
||||
|
||||
/** @var AssignAnnouncementToSegmentProcessor */
|
||||
private $assignAnnouncementToSegmentProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateAnnouncementLogic constructor.
|
||||
* @param CanCreateAnnoucement $canCreateAnnoucement
|
||||
* @param CreatesAnnoucement $createsAnnoucement
|
||||
* @param AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateAnnouncement $canCreateAnnouncement,
|
||||
CreatesAnnouncement $createsAnnoucement,
|
||||
AssignAnnouncementToSegmentProcessor $assignAnnouncementToSegmentProcessor
|
||||
) {
|
||||
$this->canCreateAnnouncement = $canCreateAnnouncement;
|
||||
$this->createsAnnoucement = $createsAnnoucement;
|
||||
$this->assignAnnouncementToSegmentProcessor = $assignAnnouncementToSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canCreateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$announcement = $this->createsAnnoucement->execute($annoucement_object);
|
||||
|
||||
$this->assignAnnouncementToSegmentProcessor->execute($announcement);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanDeleteAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\DeletesAnnouncement;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Delete Announcement',
|
||||
'message' => 'You have successfully deleted the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteAnnouncement */
|
||||
private $canDeleteAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var DeletesAnnouncement */
|
||||
private $deletesAnnouncement;
|
||||
|
||||
/**
|
||||
* DeleteAnnouncementLogic constructor.
|
||||
* @param CanDeleteAnnouncement $canDeleteAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param DeletesAnnouncement $deletesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanDeleteAnnouncement $canDeleteAnnoucement,
|
||||
FetchesAnnouncement $fetchesAnnoucement,
|
||||
DeletesAnnouncement $deletesAnnoucement
|
||||
) {
|
||||
$this->canDeleteAnnoucement = $canDeleteAnnoucement;
|
||||
$this->fetchesAnnoucement = $fetchesAnnoucement;
|
||||
$this->deletesAnnoucement = $deletesAnnoucement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteAnnoucement->passes();
|
||||
|
||||
$annoucement = $this->fetchesAnnoucement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesAnnoucement->execute($annoucement);
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Announcements\Services\ListsAnnouncements;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanListAnnouncements;
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAnnouncementsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieve Announcements',
|
||||
'message' => 'You have successfully retrieved a list of Announcements'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListAnnouncements */
|
||||
private $canListAnnouncements;
|
||||
|
||||
/** @var ListsAnnouncements */
|
||||
private $listsAnnouncements;
|
||||
|
||||
/**
|
||||
* ListAnnouncementsLogic constructor.
|
||||
* @param CanListAnnouncements $canListAnnouncements
|
||||
* @param ListsAnnouncements $listsAnnouncements
|
||||
*/
|
||||
public function __construct(CanListAnnouncements $canListAnnouncements, ListsAnnouncements $listsAnnouncements)
|
||||
{
|
||||
$this->canListAnnouncements = $canListAnnouncements;
|
||||
$this->listsAnnouncements = $listsAnnouncements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAnnouncements->passes();
|
||||
|
||||
$annoucements = $this->listsAnnouncements->execute($this->listsAnnouncements->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(AnnouncementResource::collection($annoucements));
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Announcements\Services\RemovesAnnouncementFromSegment;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveSegmentFromAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Detach Announcement From Segment',
|
||||
'message' => 'You have successfully detached Announcement from segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnnouncement;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesAnnouncementFromSegment */
|
||||
private $removesAnnouncementFromSegment;
|
||||
|
||||
/**
|
||||
* RemoveSegmentFromAnnouncementLogic constructor.
|
||||
* @param FetchesAnnouncement $fetchesAnnnouncement
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesAnnouncementFromSegment $removesAnnouncementFromSegment
|
||||
*/
|
||||
public function __construct(FetchesAnnouncement $fetchesAnnnouncement, FetchesSegment $fetchesSegment, RemovesAnnouncementFromSegment $removesAnnouncementFromSegment)
|
||||
{
|
||||
$this->fetchesAnnnouncement = $fetchesAnnnouncement;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesAnnouncementFromSegment = $removesAnnouncementFromSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$announcement = $this->fetchesAnnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesAnnouncementFromSegment->execute($announcement, $segment);
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanUpdateAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||
|
||||
use App\Http\Resources\AnnouncementResource;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class UpdateAnnouncementLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Update Announcement',
|
||||
'message' => 'You have successfully updated the Announcement'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateAnnouncement */
|
||||
private $canUpdateAnnouncement;
|
||||
|
||||
/** @var FetchesAnnouncement */
|
||||
private $fetchesAnnouncement;
|
||||
|
||||
/** @var UpdatesAnnouncement */
|
||||
private $updatesAnnouncement;
|
||||
|
||||
/**
|
||||
* UpdateAnnouncementLogic constructor.
|
||||
* @param CanUpdateAnnouncement $canUpdateAnnouncement
|
||||
* @param FetchesAnnouncement $fetchesAnnouncement
|
||||
* @param UpdatesAnnouncement $updatesAnnouncement
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateAnnouncement $canUpdateAnnouncement,
|
||||
FetchesAnnouncement $fetchesAnnouncement,
|
||||
UpdatesAnnouncement $updatesAnnouncement
|
||||
) {
|
||||
$this->canUpdateAnnouncement = $canUpdateAnnouncement;
|
||||
$this->fetchesAnnouncement = $fetchesAnnouncement;
|
||||
$this->updatesAnnouncement = $updatesAnnouncement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$annoucement_object = new AnnouncementObject(
|
||||
$request->input('title'),
|
||||
$request->input('description'),
|
||||
$request->input('starting_on'),
|
||||
$request->input('ending_on')
|
||||
);
|
||||
|
||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||
|
||||
$annoucement = $this->fetchesAnnouncement->execute(['id' => $request->route('id')]);
|
||||
|
||||
$announcement_query = $this->updatesAnnouncement->execute($annoucement, $annoucement_object);
|
||||
|
||||
//$announcement_query->segments()->sync($request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new AnnouncementResource($announcement_query));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class AnnouncementObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string */
|
||||
private $description;
|
||||
|
||||
/** @var string */
|
||||
private $starting_on;
|
||||
|
||||
/** @var string */
|
||||
private $ending_on;
|
||||
|
||||
|
||||
/**
|
||||
* AnnouncementObject constructor.
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param string $start_date
|
||||
* @param string $end_date
|
||||
*/
|
||||
|
||||
public function __construct(string $title, string $description, string $starting_on, string $ending_on)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->description = $description;
|
||||
$this->starting_on = $starting_on;
|
||||
$this->ending_on = $ending_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStartingOn(): string
|
||||
{
|
||||
return $this->starting_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEndingOn(): string
|
||||
{
|
||||
return $this->ending_on;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Processors;
|
||||
|
||||
use App\Classes\Modules\Announcements\Services\AssignsAnnouncementToSegment;
|
||||
use App\Classes\Modules\Announcements\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Announcement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignAnnouncementToSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var AssignAnnouncementToSegment */
|
||||
private $assignsAnnouncementToSegment;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AssignAnnouncementToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignAnnouncementToSegment $assignsAnnouncementToSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, FetchesSegment $fetchesSegment, AssignsAnnouncementToSegment $assignsAnnouncementToSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsAnnouncementToSegment = $assignsAnnouncementToSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Announcement $announcement
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Announcement $announcement, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model
|
||||
{
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
return $this->assignsAnnouncementToSegment->execute($announcement, $segment);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class AssignsCompanyConnectionToConnectionSegment extends AbstractUpdateRecord
|
||||
class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->attach($segment);
|
||||
$announcement->segments()->attach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class CreatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(AnnouncementObject $object)
|
||||
{
|
||||
$model = new Announcement();
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class DeletesAnnouncement extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,23 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\UserSocialAccount;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class FetchesUserSocialAccount extends AbstractFetchRecord
|
||||
class FetchesAnnouncement extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var UserSocialAccount */
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param UserSocialAccount $repository
|
||||
* FetchesAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(UserSocialAccount $repository)
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class ListsAnnouncements extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Announcement */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsAnnouncement constructor.
|
||||
* @param Announcement $repository
|
||||
*/
|
||||
public function __construct(Announcement $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\Announcement;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class RemovesCompanyConnectionFromConnectionSegment extends AbstractUpdateRecord
|
||||
class RemovesAnnouncementFromSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param Announcement $announcement
|
||||
* @param Segment $segment
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, Segment $segment)
|
||||
public function execute(Announcement $announcement, Segment $segment)
|
||||
{
|
||||
try {
|
||||
|
||||
$companyConnection->segments()->detach($segment);
|
||||
$announcement->segments()->detach($segment);
|
||||
|
||||
return $companyConnection;
|
||||
return $announcement;
|
||||
|
||||
} catch (QueryException $exception){
|
||||
throw new MalformedRequestException($exception);
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Models\Announcement;
|
||||
|
||||
class UpdatesAnnouncement extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Announcement $model
|
||||
* @param AnnouncementObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Announcement $model, AnnouncementObject $object)
|
||||
{
|
||||
$model->title = $object->getTitle();
|
||||
$model->description = $object->getDescription();
|
||||
$model->starting_on = $object->getStartingOn();
|
||||
$model->ending_on = $object->getEndingOn();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class CanAssignSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanCreateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcement\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanDeleteAnnouncement extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class CanListAnnouncements extends AbstractRule
|
||||
{
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
use App\Classes\Modules\Announcements\Standards\Validators\AnnouncementValidation;
|
||||
|
||||
class CanUpdateAnnouncement extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var AnnouncementValidation */
|
||||
private $AnnouncementValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateAnnouncement constructor.
|
||||
* @param AnnouncementValidation $AnnouncementValidation
|
||||
*/
|
||||
public function __construct(AnnouncementValidation $AnnouncementValidation)
|
||||
{
|
||||
$this->AnnouncementValidation = $AnnouncementValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->AnnouncementValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Announcements\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Announcements\DataTransferObjects\AnnouncementObject;
|
||||
|
||||
class AnnouncementValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param AnnouncementObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'title' => $object->getTitle(),
|
||||
'description' => $object->getDescription(),
|
||||
'starting_on' => $object->getStartingOn(),
|
||||
'ending_on' => $object->getEndingOn()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required',
|
||||
'description' => 'required',
|
||||
'starting_on' => 'required',
|
||||
'ending_on' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\AssignConnectionSegmentProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Assign Company Connection To Connection Segment',
|
||||
'message' => 'You have successfully assigned Company Connection to Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var AssignConnectionSegmentProcessor */
|
||||
private $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, AssignConnectionSegmentProcessor $assignCompanyConnectionToConnectionSegmentProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor = $assignCompanyConnectionToConnectionSegmentProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id'));
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\RemovesCompanyConnectionFromConnectionSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoveCompanyConnectionFromConnectionSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Detach Company Connection From Connection Segment',
|
||||
'message' => 'You have successfully detached Company Connection from Connection segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesCompany */
|
||||
private $fetchesCompany;
|
||||
|
||||
/** @var FetchesCompanyConnection */
|
||||
private $fetchesCompanyConnection;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var RemovesCompanyConnectionFromConnectionSegment */
|
||||
private $removesCompanyConnectionFromConnectionSegment;
|
||||
|
||||
/**
|
||||
* RemoveCompanyFromSegmentLogic constructor.
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
* @param FetchesCompanyConnection $fetchesCompanyConnection
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesCompanyConnection $fetchesCompanyConnection, FetchesSegment $fetchesSegment, RemovesCompanyConnectionFromConnectionSegment $removesCompanyConnectionFromConnectionSegment)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesCompanyConnection = $fetchesCompanyConnection;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->removesCompanyConnectionFromConnectionSegment = $removesCompanyConnectionFromConnectionSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
|
||||
$companyConnection = $this->fetchesCompanyConnection->execute(['id' => $request->route('company_connection_id')]);
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('segment_id')]);
|
||||
|
||||
$this->removesCompanyConnectionFromConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
return $this->resourceResponse(new CompanyResource($company));
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\AssignsCompanyConnectionToConnectionSegment;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanAssignSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\CompanyConnection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AssignConnectionSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanAssignSegment */
|
||||
private $canAssignSegment;
|
||||
|
||||
/** @var AssignsCompanyConnectionToConnectionSegment */
|
||||
private $assignsCompanyConnectionToConnectionSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* AssignCompanyToSegmentProcessor constructor.
|
||||
* @param CanAssignSegment $canAssignSegment
|
||||
* @param AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanAssignSegment $canAssignSegment, AssignsCompanyConnectionToConnectionSegment $assignsCompanyConnectionToConnectionSegment, FetchesSegment $fetchesSegment)
|
||||
{
|
||||
$this->canAssignSegment = $canAssignSegment;
|
||||
$this->assignsCompanyConnectionToConnectionSegment = $assignsCompanyConnectionToConnectionSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyConnection $companyConnection
|
||||
* @param int|null $segmentId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(CompanyConnection $companyConnection, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model {
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $segmentId]);
|
||||
|
||||
$this->canAssignSegment->passes();
|
||||
|
||||
return $this->assignsCompanyConnectionToConnectionSegment->execute($companyConnection, $segment);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CreatesOrderRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignOrderRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesOrderRemark */
|
||||
private $createsOrderRemark;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesOrderRemark $createsOrderRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesOrderRemark $createsOrderRemark, FetchesOrder $fetchesOrder)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsOrderRemark = $createsOrderRemark;
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsOrderRemark->execute($this->fetchesOrder->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -64,13 +63,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]);
|
||||
|
||||
if($originWarehouse->reference === WarehouseReferences::VT_GUANG_ZHOU){
|
||||
$marking = $company->companyModules()->importers()->first()->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||
if(in_array($marking, ['2192KAA', '2353GFE', '6866DTR', '1905JYW', '1291NSC', '8288MIB'])){
|
||||
$originWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::YD_GUANG_ZHOU]);
|
||||
}
|
||||
}
|
||||
|
||||
$order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute());
|
||||
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
|
||||
@@ -19,7 +19,6 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\TransportType;
|
||||
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Models\PackingList;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
@@ -81,9 +80,6 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
@@ -97,8 +93,6 @@ class CreateShippingPackingListLogic extends AbstractControllerLogic
|
||||
PackingListType::SHIPPING_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
/** @var PackingList $packingList */
|
||||
$packingList = $this->createPackingListProcessor->execute($packingListObject, $order);
|
||||
|
||||
$packages = $request->input('packages');
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesCBM;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesBaseRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesSegmentRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesStateRate;
|
||||
use App\Classes\Modules\Orders\Services\CalculatesWarehouseRate;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Classes\Modules\Transactions\Processors\CreateShippingCostTransactionProcessor;
|
||||
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShippingCostLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Order Shipping Cost',
|
||||
'message' => 'Order shipping cost calculation done'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CalculateCBM */
|
||||
private $calculateCBM;
|
||||
|
||||
/** @var CalculatesBaseRate */
|
||||
private $calculateBaseRate;
|
||||
|
||||
/** @var CalculatesSegmentRate */
|
||||
private $calculateSegmentRate;
|
||||
|
||||
/** @var CalculatesStateRate */
|
||||
private $calculateStateRate;
|
||||
|
||||
/** @var CalculatesWarehouse */
|
||||
private $calculateWarehouseRate;
|
||||
|
||||
/** @var FetchesOrder */
|
||||
private $fetchesOrder;
|
||||
|
||||
/** @var ShippingCostTransactionProcessor */
|
||||
private $shippingCostTransactionProcessor;
|
||||
|
||||
/**
|
||||
* ShippingCostLogic constructor.
|
||||
* @param CalculateCBM $calculateCBM
|
||||
* @param FetchesOrder $fetchesOrder
|
||||
*/
|
||||
public function __construct(FetchesOrder $fetchesOrder, CalculatesCBM $calculateCBM, CalculatesBaseRate $calculateBaseRate, CalculatesSegmentRate $calculateSegmentRate, CalculatesStateRate $calculateStateRate, CalculatesWarehouseRate $calculateWarehouseRate, CreateShippingCostTransactionProcessor $shippingCostTransactionProcessor)
|
||||
{
|
||||
$this->fetchesOrder = $fetchesOrder;
|
||||
$this->calculateCBM = $calculateCBM;
|
||||
$this->calculatesBaseRate = $calculateBaseRate;
|
||||
$this->calculatesSegmentRate = $calculateSegmentRate;
|
||||
$this->calculatesStateRate = $calculateStateRate;
|
||||
$this->calculateWarehouseRate = $calculateWarehouseRate;
|
||||
$this->shippingCostTransactionProcessor = $shippingCostTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$order = $this->fetchesOrder->getRepository()->where(['id' => $request->route('id')])->first();
|
||||
|
||||
$baseRate = $this->calculatesBaseRate->execute($order);
|
||||
$segmentRate = $this->calculatesSegmentRate->execute($order, SegmentConstants::STANDARD_SEGMENT) + $this->calculatesSegmentRate->execute($order, SegmentConstants::CUSTOM_SEGMENT);
|
||||
$stateRate = $this->calculatesStateRate->execute($order, false) + $this->calculatesStateRate->execute($order, true);
|
||||
$warehouseRate = $this->calculateWarehouseRate->execute($order);
|
||||
|
||||
$totalShippingCost = 0;
|
||||
$totalCBM = 0;
|
||||
$quantity = 0;
|
||||
foreach($order->parcels as $parcel){
|
||||
$cbm = $this->calculateCBM->execute($order, $parcel);
|
||||
|
||||
if($cbm > 0){
|
||||
$totalCBM += $cbm;
|
||||
$quantity ++;
|
||||
$totalShippingCost += (($segmentRate + $stateRate + $warehouseRate) * $cbm);
|
||||
}
|
||||
}
|
||||
|
||||
$this->shippingCostTransactionProcessor->execute($order, $quantity, round($totalCBM,2), round($totalShippingCost,2));
|
||||
return $this->resourceResponse(new OrderResource($order));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class CreateOrderRolesProcessor
|
||||
$importer = $order->companyModule;
|
||||
|
||||
/** @var CompanyModule $destinationWarehouse */
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => $originWarehouse->reference === WarehouseReferences::YD_GUANG_ZHOU ? WarehouseReferences::YD_DESTINATION_WAREHOUSE : WarehouseReferences::VT_DESTINATION_WAREHOUSE[$address->state_id]]);
|
||||
$destinationWarehouse = $this->fetchesCompanyModule->execute(['reference' => WarehouseReferences::DESTINATION_WAREHOUSE[$address->state_id ]]);
|
||||
|
||||
/** @var CompanyModule $freightForwarder */
|
||||
$freightForwarder = $originWarehouse->company->companyModules()->freightForwarders()->first();
|
||||
@@ -84,5 +84,28 @@ class CreateOrderRolesProcessor
|
||||
$this->createsOrderRole->execute($roleObject);
|
||||
|
||||
return true;
|
||||
|
||||
$companies = $this->fetchesCompany->getRepository()->whereIn('id',[1, $request->get('warehouse_id')])->get();
|
||||
|
||||
$cief_company = $companies[0]->id == 1 ? $companies[0] : $companies[1];
|
||||
$warehouse_company = $companies[0]->id != 1 ? $companies[0] : $companies[1];
|
||||
|
||||
$cief_company_module = $cief_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$cief_company_module->unity_hash_id]);
|
||||
$contractEntities[0]->{"company_module_id"} = $cief_company_module->id;
|
||||
|
||||
$warehouse_company_module = $warehouse_company->companyModule()->first();
|
||||
$contractEntities[] = $this->unityCreateContractEntity->execute( $contract_reference_no, [$warehouse_company_module->unity_hash_id]);
|
||||
$contractEntities[1]->{"company_module_id"} = $warehouse_company_module->id;
|
||||
|
||||
foreach($contractEntities as $entity){
|
||||
$order_role_object = new OrderRoleObject($orderId, $entity->company_module_id, $entity->hash_id, $entity->entity_signature_hash_id);
|
||||
|
||||
$this->canCreateOrderRole->passes($order_role_object);
|
||||
|
||||
$this->createsOrderRole->execute($order_role_object);
|
||||
}
|
||||
|
||||
return $contractEntities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesBaseRate
|
||||
{
|
||||
|
||||
public function execute(Order $order){
|
||||
return 300;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Package;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesCBM
|
||||
{
|
||||
|
||||
public function execute(Order $order, Package $parcel){
|
||||
return $parcel->length * $parcel->width * $parcel->height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesSegmentRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, int $segmentRates){
|
||||
return ($segmentRates == SegmentConstants::STANDARD_SEGMENT) ? 300 : (
|
||||
(($segmentRates == SegmentConstants::CUSTOM_SEGMENT) ? -20 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesStateRate
|
||||
{
|
||||
|
||||
public function execute(Order $order, $isOutskirt=false){
|
||||
return ($isOutskirt) ? 20 : 40;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class CalculatesWarehouseRate
|
||||
{
|
||||
|
||||
public function execute(Order $order){
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Orders\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Order;
|
||||
|
||||
class CreatesOrderRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Order $order, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($order->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\CreatesPackingListRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignPackingListRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Packing List Remark',
|
||||
'message' => 'You have successfully created a new Packing List Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesPackingListRemark */
|
||||
private $createsPackingListRemark;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesPackingListRemark $createsPackingListRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesPackingListRemark $createsPackingListRemark, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsPackingListRemark = $createsPackingListRemark;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsPackingListRemark->execute($this->fetchesPackingList->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\CreatesContainerRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
|
||||
use App\Http\Resources\RemarkResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AssignContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Order Remark',
|
||||
'message' => 'You have successfully created a new Order Remark'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/** @var CreatesContainerRemark */
|
||||
private $createsContainerRemark;
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/**
|
||||
* CreateRemarkLogic constructor.
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
* @param CreatesContainerRemark $createsContainerRemark
|
||||
*/
|
||||
public function __construct(CanCreateRemark $canCreateRemark, CreatesContainerRemark $createsContainerRemark, FetchesContainer $fetchesContainer)
|
||||
{
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
$this->createsContainerRemark = $createsContainerRemark;
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject(
|
||||
$request->input('content'),
|
||||
$request->route('id')
|
||||
);
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
$query = $this->createsContainerRemark->execute($this->fetchesContainer->execute(['id' => $request->route('id')]), $object);
|
||||
return $this->resourceResponse( new RemarkResource($query));
|
||||
}
|
||||
}
|
||||
+14
-21
@@ -4,17 +4,16 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Models\Container;
|
||||
use App\Models\Remark;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -25,41 +24,35 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesContainer */
|
||||
private $fetchesContainer;
|
||||
|
||||
/** @var CreateRemarkProcessor */
|
||||
private $createRemarkProcessor;
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/**
|
||||
* CreateContainerRemarkLogic constructor.
|
||||
* @param FetchesContainer $fetchesContainer
|
||||
* @param CreateRemarkProcessor $createRemarkProcessor
|
||||
* @param CreatesRemark $createsRemark
|
||||
*/
|
||||
public function __construct(FetchesContainer $fetchesContainer, CreateRemarkProcessor $createRemarkProcessor)
|
||||
public function __construct(CreatesRemark $createsRemark)
|
||||
{
|
||||
$this->fetchesContainer = $fetchesContainer;
|
||||
$this->createRemarkProcessor = $createRemarkProcessor;
|
||||
$this->createsRemark = $createsRemark;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
// get the container
|
||||
$container = Container::findOrFail($request->input('container_id'));
|
||||
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
$object = new RemarkObject($request->input('content'), 1);
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
$remark = $this->createsRemark->execute($container, $object);
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
return $remark;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PackingLists\Processors\CreatePackingListProcessor;
|
||||
use App\Classes\Modules\PackingLists\Services\GeneratesPackingListReferenceNumber;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CreatePackingListProcessor */
|
||||
private $createPackingListProcessor;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var GeneratesPackingListReferenceNumber */
|
||||
private $generatesPackingListReferenceNumber;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/**
|
||||
* CreateDeliverPackingListLogic constructor.
|
||||
* @param CreatePackingListProcessor $createPackingListProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
*/
|
||||
public function __construct(CreatePackingListProcessor $createPackingListProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesPackingListReferenceNumber $generatesPackingListReferenceNumber, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->createPackingListProcessor = $createPackingListProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesPackingListReferenceNumber = $generatesPackingListReferenceNumber;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$deliverPackingList = $this->createPackingListProcessor->execute($packingListObject, $company_module);
|
||||
|
||||
foreach ($packing_list_id as $key => $row) {
|
||||
$this->fetchesPackingList->execute(['id' => $row]);
|
||||
}
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class PackingListObject implements DataTransferObject
|
||||
* @param int $status
|
||||
* @param null|string $contractReference
|
||||
*/
|
||||
public function __construct(string $reference, ?int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
public function __construct(string $reference, int $claimantId, int $type, int $status, ?string $contractReference = null)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
$this->claimantId = $claimantId;
|
||||
@@ -50,7 +50,7 @@ class PackingListObject implements DataTransferObject
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getClaimantId(): ?int
|
||||
public function getClaimantId(): int
|
||||
{
|
||||
return $this->claimantId;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,6 @@ class FetchDeliveryListFromVTPortalProcessor
|
||||
|
||||
$shippingPackingLists = $this->fetchesDataFRomVTPortal->getResponseBody($shippingPackingListsRequest);
|
||||
|
||||
if(!array_key_exists(0, $shippingPackingLists->Rows)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$shippingPackingList = $shippingPackingLists->Rows[0];
|
||||
|
||||
if(!$shippingPackingList[9] && !$shippingPackingList[10]) {
|
||||
@@ -91,7 +87,6 @@ class FetchDeliveryListFromVTPortalProcessor
|
||||
$deliveryStep->update(['status' => ApprovalStatus::COMPLETED]);
|
||||
|
||||
} catch (GuzzleException $exception) {
|
||||
dd($exception);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services\Containers;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\Container;
|
||||
|
||||
class CreatesContainerRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Container $container, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($container->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ class CreatesPackingList extends AbstractUpdateRelationshipRecord
|
||||
$model->claimant_id = $object->getClaimantId();
|
||||
$model->type = $object->getType();
|
||||
$model->status = $object->getStatus();
|
||||
$model->reference_contract = $object->getContractReference();
|
||||
|
||||
return $this->handler($packable->packingLists(), $model);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Models\Remark;
|
||||
use App\Models\PackingList;
|
||||
|
||||
class CreatesPackingListRemark extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Company $company
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(PackingList $packingList, RemarkObject $object) {
|
||||
$model = new Remark();
|
||||
|
||||
$model->commenter_id = $object->getCommenterId();
|
||||
$model->content = $object->getContent();
|
||||
|
||||
return $this->handler($packingList->remarks(), $model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,11 @@ class UpdateRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new RemarkObject($request->input('content'), auth()->user()->id);
|
||||
$object = new RemarkObject($request->input('content'), $request->input('commenter_id'));
|
||||
|
||||
$this->canUpdateRemark->passes($object);
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Remarks\Processors;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Services\CreatesRemark;
|
||||
use App\Classes\Modules\Remarks\Standards\Rules\CanCreateRemark;
|
||||
|
||||
class CreateRemarkProcessor
|
||||
{
|
||||
|
||||
/** @var CreatesRemark */
|
||||
private $createsRemark;
|
||||
|
||||
/** @var CanCreateRemark */
|
||||
private $canCreateRemark;
|
||||
|
||||
/**
|
||||
* CreateRemarkProcessor constructor.
|
||||
* @param CreatesRemark $createsRemark
|
||||
* @param CanCreateRemark $canCreateRemark
|
||||
*/
|
||||
public function __construct(CreatesRemark $createsRemark, CanCreateRemark $canCreateRemark)
|
||||
{
|
||||
$this->createsRemark = $createsRemark;
|
||||
$this->canCreateRemark = $canCreateRemark;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Remarkable $remarkable
|
||||
* @param RemarkObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Remarkable $remarkable, RemarkObject $object){
|
||||
|
||||
$this->canCreateRemark->passes($object);
|
||||
return $this->createsRemark->execute($remarkable, $object);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,16 @@
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Processors\CreateSegmentProcessor;
|
||||
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateSegment;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use App\Models\Segment;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -22,17 +27,22 @@ class CreateSegmentLogic extends AbstractControllerLogic
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateSegment */
|
||||
private $canCreateSegment;
|
||||
|
||||
/** @var CreatesSegment */
|
||||
private $createsSegment;
|
||||
|
||||
/** @var CreateSegmentProcessor */
|
||||
private $createSegmentProcessor;
|
||||
|
||||
/**
|
||||
* CreateSegmentLogic constructor.
|
||||
* @param CreateSegmentProcessor $createSegmentProcessor
|
||||
* @param CanCreateSegment $canCreateSegment
|
||||
* @param CreatesSegment $createsSegment
|
||||
*/
|
||||
public function __construct(CreateSegmentProcessor $createSegmentProcessor)
|
||||
public function __construct(CanCreateSegment $canCreateSegment, CreatesSegment $createsSegment)
|
||||
{
|
||||
$this->createSegmentProcessor = $createSegmentProcessor;
|
||||
$this->canCreateSegment = $canCreateSegment;
|
||||
$this->createsSegment = $createsSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +54,12 @@ class CreateSegmentLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
/** @var Segment $segment */
|
||||
$segment = $this->createSegmentProcessor->execute($request->input('name'));
|
||||
$segment_object = new SegmentObject($request->input('name'));
|
||||
|
||||
$this->canCreateSegment->passes($segment_object);
|
||||
$segment = $this->createsSegment->execute($segment_object);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,31 @@
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\SegmentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\DeletesSegment;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanDeleteSegment;
|
||||
use App\Classes\Modules\Segments\Services\DeletesSegment;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Deleted Segment',
|
||||
'message' => 'You have successfully deleted a Segment'
|
||||
'title' => 'Delete Segment',
|
||||
'message' => 'You have successfully deleted the Segment'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var CanDeleteSegment */
|
||||
private $canDeleteSegment;
|
||||
|
||||
@@ -32,20 +36,24 @@ class DeleteSegmentLogic extends AbstractControllerLogic
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
|
||||
/**
|
||||
* DeleteSegmentLogic constructor.
|
||||
* @param CanDeleteSegment $canDeleteSegment
|
||||
* @param DeletesSegment $deletesSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanDeleteSegment $canDeleteSegment, DeletesSegment $deletesSegment, FetchesSegment $fetchesSegment)
|
||||
public function __construct(
|
||||
CanDeleteSegment $canDeleteSegment,
|
||||
DeletesSegment $deletesSegment,
|
||||
FetchesSegment $fetchesSegment
|
||||
)
|
||||
{
|
||||
$this->canDeleteSegment = $canDeleteSegment;
|
||||
$this->deletesSegment = $deletesSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
@@ -56,14 +64,11 @@ class DeleteSegmentLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
$this->canDeleteSegment->passes();
|
||||
$this->deletesSegment->execute($segment_query);
|
||||
|
||||
$query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesSegment->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Fetch Segment Constant',
|
||||
'message' => 'You have successfully retrieved the Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/**
|
||||
* FetchConstantLogic constructor.
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
*/
|
||||
public function __construct(FetchesConstant $fetchesConstant)
|
||||
{
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $request->route('id'), 'reference' => $request->route('reference')]);
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanFetchSegment;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Segment',
|
||||
'message' => 'You have successfully retrieved a segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchSegment */
|
||||
private $canFetchSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* FetchSegmentLogic constructor.
|
||||
* @param CanFetchSegment $canFetchSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(CanFetchSegment $canFetchSegment, FetchesSegment $fetchesSegment)
|
||||
{
|
||||
$this->canFetchSegment = $canFetchSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchSegment->passes();
|
||||
|
||||
$query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\ListsSegments;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Segment',
|
||||
'message' => 'You have successfully retrieved a list of Segment'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var ListsSegments */
|
||||
private $listsSegments;
|
||||
|
||||
/**
|
||||
* ListSegmentLogic constructor.
|
||||
* @param ListsSegments $listsSegments
|
||||
*/
|
||||
public function __construct(ListsSegments $listsSegments)
|
||||
{
|
||||
$this->listsSegments = $listsSegments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->listsSegments->execute($this->listsSegments->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(SegmentResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateConstant;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment Constant',
|
||||
'message' => 'You have successfully updated the Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateConstant */
|
||||
private $canUpdateConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var CanCreateConstant */
|
||||
private $canCreateConstant;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateConstantLogic constructor.
|
||||
* @param CanUpdateConstant $canUpdateConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param CanCreateConstant $canCreateConstant
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(CanUpdateConstant $canUpdateConstant, UpdatesConstant $updatesConstant, FetchesSegment $fetchesSegment, FetchesConstant $fetchesConstant, CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->canUpdateConstant = $canUpdateConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->canCreateConstant = $canCreateConstant;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new ConstantObject($request->input('name'), $request->input('reference'), $request->input('detail'));
|
||||
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $object->getReference()]);
|
||||
$this->canUpdateConstant->passes($object);
|
||||
|
||||
/** @var SegmentConstant $constant */
|
||||
$constant = $this->updatesConstant->execute($constant, $object);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$this->canCreateConstant->passes($object);
|
||||
|
||||
/** @var SegmentConstant $constant */
|
||||
$constant = $this->createsConstant->execute($segment, $object);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\SegmentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanUpdateSegment;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesSegment;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment',
|
||||
'message' => 'You have successfully updated the Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateSegment */
|
||||
private $canUpdateSegment;
|
||||
|
||||
/** @var UpdatesSegment */
|
||||
private $updatesSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateSegmentLogic constructor.
|
||||
* @param CanUpdateSegment $canUpdateSegment
|
||||
* @param UpdatesSegment $updatesSegment
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateSegment $canUpdateSegment,
|
||||
UpdatesSegment $updatesSegment,
|
||||
FetchesSegment $fetchesSegment
|
||||
)
|
||||
{
|
||||
$this->canUpdateSegment = $canUpdateSegment;
|
||||
$this->updatesSegment = $updatesSegment;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
$segment_object = new SegmentObject(
|
||||
$request->input('name', $segment_query->name)
|
||||
);
|
||||
$this->canUpdateSegment->passes($segment_object);
|
||||
$segment_query = $this->updatesSegment->execute($segment_query, $segment_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,26 +3,25 @@
|
||||
namespace App\Classes\Modules\Segments\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
|
||||
class SegmentObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var int */
|
||||
private $company_module_id;
|
||||
/** @var int|null */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* ConstantObject constructor.
|
||||
* SegmentObject constructor.
|
||||
* @param string $name
|
||||
* @param string $reference
|
||||
* @param array $detail
|
||||
* @param int|null $type
|
||||
*/
|
||||
public function __construct(string $name, int $company_module_id)
|
||||
public function __construct(string $name, ?int $type = SegmentConstants::STANDARD_SEGMENT)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->company_module_id = $company_module_id;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,11 +33,16 @@ class SegmentObject implements DataTransferObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getCompanyModuleId(): string
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->company_module_id;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Processors;
|
||||
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesSegment;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanCreateSegment;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateSegmentProcessor
|
||||
{
|
||||
|
||||
/** @var CanCreateSegment */
|
||||
private $canCreateSegment;
|
||||
|
||||
/** @var CreatesSegment */
|
||||
private $createsSegment;
|
||||
|
||||
/**
|
||||
* CreateSegmentProcessor constructor.
|
||||
* @param CanCreateSegment $canCreateSegment
|
||||
* @param CreatesSegment $createsSegment
|
||||
* @param GeneratesUniqueAccountNumber $generatesUniqueAccountNumber
|
||||
*/
|
||||
public function __construct(CanCreateSegment $canCreateSegment, CreatesSegment $createsSegment)
|
||||
{
|
||||
$this->canCreateSegment = $canCreateSegment;
|
||||
$this->createsSegment = $createsSegment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param int $companyModuleId
|
||||
* @return Model
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(string $name, int $companyModuleId =1): Model {
|
||||
|
||||
$segement_object = new SegmentObject($name, $companyModuleId);
|
||||
|
||||
$this->canCreateSegment->passes($segement_object);
|
||||
|
||||
return $this->createsSegment->execute($segement_object);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\Modules\Currencies\Services\FetchesCurrency;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use App\Http\Resources\CurrencyResource;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class ConvertsConstantDetailsToResource
|
||||
{
|
||||
|
||||
/** @var FetchesCurrency */
|
||||
private $fetchesCurrency;
|
||||
|
||||
/**
|
||||
* ConvertsConstantDetailsToResource constructor.
|
||||
* @param FetchesCurrency $fetchesCurrency
|
||||
*/
|
||||
public function __construct(FetchesCurrency $fetchesCurrency)
|
||||
{
|
||||
$this->fetchesCurrency = $fetchesCurrency;
|
||||
}
|
||||
|
||||
|
||||
public function execute(SegmentConstant $constant){
|
||||
|
||||
if($constant->reference === SegmentConstants::SUPPLIER_CURRENCIES) {
|
||||
return property_exists($constant->detail, 'id') ? new CurrencyResource($this->fetchesCurrency->execute(['id' => $constant->detail->id])) : '';
|
||||
}
|
||||
|
||||
return $constant->detail;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,22 +4,22 @@ namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegment extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentObject $object)
|
||||
{
|
||||
public function execute(SegmentObject $object) {
|
||||
$model = new Segment();
|
||||
$model->name = $object->getName();
|
||||
$model->company_module_id = $object->getCompanyModuleId();
|
||||
$model->type = SegmentConstants::CUSTOM_SEGMENT;
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -1,24 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\CompanyConnection;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class FetchesCompanyConnection extends AbstractFetchRecord
|
||||
class FetchesConstant extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var CompanyConnection */
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
|
||||
/**
|
||||
* FetchesCompanyConnection constructor.
|
||||
* @param CompanyConnection $repository
|
||||
* FetchesConstant constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(CompanyConnection $repository)
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class ListsConstants extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsConstants constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Segment;
|
||||
|
||||
class ListsSegments extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Segment */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsSegments constructor.
|
||||
* @param Segment $repository
|
||||
*/
|
||||
public function __construct(Segment $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesConstant extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstant $model
|
||||
* @param ConstantObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, ConstantObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode($object->getDetail());
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Models\Segment;
|
||||
|
||||
class UpdatesSegment extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Segment $model
|
||||
* @param SegmentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $model, SegmentObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\ConstantValidation;
|
||||
|
||||
class CanCreateConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ConstantValidation */
|
||||
private $constantValidation;
|
||||
|
||||
/**
|
||||
* CanCreateConstant constructor.
|
||||
* @param ConstantValidation $constantValidation
|
||||
*/
|
||||
public function __construct(ConstantValidation $constantValidation)
|
||||
{
|
||||
$this->constantValidation = $constantValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->constantValidation->validate($object, 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,17 @@ use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
||||
|
||||
class CanCreateSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentValidation */
|
||||
private $segmentValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanCreateSegment constructor.
|
||||
* @param SegmentValidation $segmentValidation
|
||||
*/
|
||||
public function __construct(SegmentValidation $segmentValidation)
|
||||
{
|
||||
$this->segmentValidation = $segmentValidation;
|
||||
$this->segmentValidation = $segmentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +27,10 @@ class CanCreateSegment extends AbstractRule
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
// if (!\Auth::user()->can('add segment')) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,17 @@ class CanDeleteSegment extends AbstractRule
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('delete segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BankObject $object
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
@@ -29,7 +34,7 @@ class CanDeleteSegment extends AbstractRule
|
||||
|
||||
|
||||
/**
|
||||
* @param BankObject $object
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
class CanFetchSegment extends AbstractRule
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanListSegments extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\ConstantValidation;
|
||||
|
||||
class CanUpdateConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var ConstantValidation */
|
||||
private $ConstantValidation;
|
||||
|
||||
/**
|
||||
* CanUpdateConstant constructor.
|
||||
* @param ConstantValidation $ConstantValidation
|
||||
*/
|
||||
public function __construct(ConstantValidation $ConstantValidation)
|
||||
{
|
||||
$this->ConstantValidation = $ConstantValidation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->ConstantValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
||||
|
||||
class CanUpdateSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentValidation */
|
||||
private $segmentValidation;
|
||||
|
||||
|
||||
/**
|
||||
* CanUpdateSegment constructor.
|
||||
* @param SegmentValidation $segmentValidation
|
||||
*/
|
||||
public function __construct(SegmentValidation $segmentValidation)
|
||||
{
|
||||
$this->segmentValidation = $segmentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('edit segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Validators;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
|
||||
class ConstantValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param ConstantObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
|
||||
$data = [
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'detail' => $object->getDetail()
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'detail' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,36 +11,28 @@ class SegmentValidation extends AbstractValidation
|
||||
* @param SegmentObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'name' => $object->getName(),
|
||||
'company_module_id' => $object->getCompanyModuleId()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(?string $type = 'POST'): array
|
||||
protected function rules(): array
|
||||
{
|
||||
if ($type == 'POST') {
|
||||
return [
|
||||
'name' => 'required',
|
||||
'company_module_id' => 'required',
|
||||
];
|
||||
} elseif ($type == 'PUT') {
|
||||
return [
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceCurrencyRates;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanCreateServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use App\Models\ServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Service Type',
|
||||
'message' => 'You have successfully created a new Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateServiceType */
|
||||
private $canCreateServiceType;
|
||||
|
||||
/** @var CreatesServiceType */
|
||||
private $createsServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var UpdatesServiceCurrencyRates */
|
||||
private $updatesServiceCurrencyRates;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
|
||||
/**
|
||||
* CreateServiceTypeLogic constructor.
|
||||
* @param CanCreateServiceType $canCreateServiceType
|
||||
* @param CreatesServiceType $createsServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param UpdatesServiceCurrencyRates $updatesServiceCurrencyRates
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(CanCreateServiceType $canCreateServiceType, CreatesServiceType $createsServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, UpdatesServiceCurrencyRates $updatesServiceCurrencyRates, FetchesSegment $fetchesSegment, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->canCreateServiceType = $canCreateServiceType;
|
||||
$this->createsServiceType = $createsServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->updatesServiceCurrencyRates = $updatesServiceCurrencyRates;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$object = new ServiceTypeObject($request->input('name'));
|
||||
|
||||
$this->canCreateServiceType->passes($object);
|
||||
|
||||
/** @var ServiceType $service */
|
||||
$service = $this->createsServiceType->execute($object);
|
||||
|
||||
$object = new ServiceDetailObject($service->id, (int) $request->input('configurations.bank_id'),
|
||||
$request->input('configurations.service_charge'), $request->input('configurations.minimum_charge'), $request->input('configurations.tax'),
|
||||
$request->input('configurations.po_limit'), $request->input('configurations.currencies'), false, $request->input('configurations.billable'));
|
||||
|
||||
$this->updatesServiceCurrencyRates->execute($service, $object->getCurrencies());
|
||||
|
||||
$constantObject = new ConstantObject('Service Type', SegmentConstants::SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object));
|
||||
|
||||
$this->createsConstant->execute($this->fetchesSegment->execute(['type' => SegmentConstants::STANDARD_SEGMENT]), $constantObject);
|
||||
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($service));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\DeletesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanDeleteServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Deleted Service Type',
|
||||
'message' => 'You have successfully deleted a Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var CanDeleteServiceType */
|
||||
private $canDeleteServiceType;
|
||||
|
||||
/** @var DeletesServiceType */
|
||||
private $deletesServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/**
|
||||
* DeleteServiceTypeLogic constructor.
|
||||
* @param CanDeleteServiceType $canDeleteServiceType
|
||||
* @param DeletesServiceType $deletesServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
*/
|
||||
public function __construct(CanDeleteServiceType $canDeleteServiceType, DeletesServiceType $deletesServiceType, FetchesServiceType $fetchesServiceType)
|
||||
{
|
||||
$this->canDeleteServiceType = $canDeleteServiceType;
|
||||
$this->deletesServiceType = $deletesServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canDeleteServiceType->passes();
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->deletesServiceType->execute($query);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanFetchServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Service Type',
|
||||
'message' => 'You have successfully retrieved a Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchServiceType */
|
||||
private $canFetchServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/**
|
||||
* FetchServiceTypeLogic constructor.
|
||||
* @param CanFetchServiceType $canFetchServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
*/
|
||||
public function __construct(CanFetchServiceType $canFetchServiceType, FetchesServiceType $fetchesServiceType)
|
||||
{
|
||||
$this->canFetchServiceType = $canFetchServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchServiceType->passes();
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\ListsServiceTypes;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanListServiceTypes;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListServiceTypesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Service Types',
|
||||
'message' => 'You have successfully retrieved a list of Service Types'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListServiceTypes */
|
||||
private $canListServiceTypes;
|
||||
|
||||
/** @var ListsServiceTypes */
|
||||
private $listsServiceTypes;
|
||||
|
||||
/**
|
||||
* ListServiceTypesControllerLogic constructor.
|
||||
* @param CanListServiceTypes $canListServiceTypes
|
||||
* @param ListsServiceTypes $listsServiceTypes
|
||||
*/
|
||||
public function __construct(CanListServiceTypes $canListServiceTypes, ListsServiceTypes $listsServiceTypes)
|
||||
{
|
||||
$this->canListServiceTypes = $canListServiceTypes;
|
||||
$this->listsServiceTypes = $listsServiceTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListServiceTypes->passes();
|
||||
|
||||
$query = $this->listsServiceTypes->execute($this->listsServiceTypes->deserializeFilters($request->input('filters')));
|
||||
|
||||
return $this->collectionResponse(ServiceTypeResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\CreatesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\CustomServiceTypeResource;
|
||||
use App\Models\Segment;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCustomServiceConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Segment Service',
|
||||
'message' => 'You have successfully update a segments service configuration'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var CreatesConstant */
|
||||
private $createsConstant;
|
||||
|
||||
/**
|
||||
* UpdateCustomServiceConstantLogic constructor.
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param CreatesConstant $createsConstant
|
||||
*/
|
||||
public function __construct(FetchesServiceType $fetchesServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, FetchesSegment $fetchesSegment, FetchesConstant $fetchesConstant, UpdatesConstant $updatesConstant, CreatesConstant $createsConstant)
|
||||
{
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->fetchesSegment = $fetchesSegment;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->createsConstant = $createsConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$service = $this->fetchesServiceType->execute(['id' => $request->input('id')]);
|
||||
|
||||
$customFields = $request->input('custom_fields');
|
||||
|
||||
$object = new ServiceDetailObject($service->id, $customFields['bank_id'], $customFields['service_charge'],
|
||||
$customFields['minimum_charge'], $customFields['tax'], $customFields['po_limit'], $request->input('configurations.currencies'),
|
||||
$request->input('configurations.active'), true);
|
||||
|
||||
$constantObject = new ConstantObject('Custom Service Type', SegmentConstants::CUSTOM_SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object, true));
|
||||
|
||||
/** @var Segment $segment */
|
||||
$segment = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
|
||||
try {
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'custom_service_type' => $object->getId()]);
|
||||
|
||||
$this->updatesConstant->execute($constant, $constantObject);
|
||||
|
||||
} catch (ResourceNotFoundException $exception){
|
||||
|
||||
$constant = $this->createsConstant->execute($segment, $constantObject);
|
||||
}
|
||||
|
||||
|
||||
return $this->resourceResponse(new CustomServiceTypeResource($constant));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\Modules\Segments\Services\UpdatesConstant;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceDetailObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\CreatesServiceTypeConstantDetails;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceCurrencyRates;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanUpdateServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ServiceTypeResource;
|
||||
use App\Models\ServiceType;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateServiceTypeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Service Type',
|
||||
'message' => 'You have successfully updated the Service Type'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateServiceType */
|
||||
private $canUpdateServiceType;
|
||||
|
||||
/** @var UpdatesServiceType */
|
||||
private $updatesServiceType;
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var CreatesServiceTypeConstantDetails */
|
||||
private $createsServiceTypeConstantDetails;
|
||||
|
||||
/** @var UpdatesServiceCurrencyRates */
|
||||
private $updatesServiceCurrencyRates;
|
||||
|
||||
/** @var UpdatesConstant */
|
||||
private $updatesConstant;
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
|
||||
/**
|
||||
* UpdateServiceTypeLogic constructor.
|
||||
* @param CanUpdateServiceType $canUpdateServiceType
|
||||
* @param UpdatesServiceType $updatesServiceType
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails
|
||||
* @param UpdatesServiceCurrencyRates $updatesServiceCurrencyRates
|
||||
* @param UpdatesConstant $updatesConstant
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
*/
|
||||
public function __construct(CanUpdateServiceType $canUpdateServiceType, UpdatesServiceType $updatesServiceType, FetchesServiceType $fetchesServiceType, CreatesServiceTypeConstantDetails $createsServiceTypeConstantDetails, UpdatesServiceCurrencyRates $updatesServiceCurrencyRates, UpdatesConstant $updatesConstant, FetchesConstant $fetchesConstant)
|
||||
{
|
||||
$this->canUpdateServiceType = $canUpdateServiceType;
|
||||
$this->updatesServiceType = $updatesServiceType;
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->createsServiceTypeConstantDetails = $createsServiceTypeConstantDetails;
|
||||
$this->updatesServiceCurrencyRates = $updatesServiceCurrencyRates;
|
||||
$this->updatesConstant = $updatesConstant;
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ServiceTypeObject($request->input('name'));
|
||||
|
||||
$this->canUpdateServiceType->passes($object);
|
||||
|
||||
$service = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
/** @var ServiceType $service */
|
||||
$service = $this->updatesServiceType->execute($service, $object);
|
||||
|
||||
$object = new ServiceDetailObject($service->id, (int) $request->input('configurations.bank_id'),
|
||||
$request->input('configurations.service_charge'), $request->input('configurations.minimum_charge'), $request->input('configurations.tax'),
|
||||
$request->input('configurations.po_limit'), $request->input('configurations.currencies'), $request->input('configurations.active'), $request->input('configurations.billable'));
|
||||
|
||||
$this->updatesServiceCurrencyRates->execute($service, $object->getCurrencies());
|
||||
|
||||
$constantObject = new ConstantObject('Service Type', SegmentConstants::SERVICE_TYPE, $this->createsServiceTypeConstantDetails->execute($object));
|
||||
|
||||
$this->updatesConstant->execute($this->fetchesConstant->execute(['service_type' => $service->id]), $constantObject);
|
||||
|
||||
return $this->resourceResponse(new ServiceTypeResource($service));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceType;
|
||||
use App\Classes\Modules\ServiceTypes\Services\UpdatesServiceTypeStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateServiceTypeStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Service Type',
|
||||
'message' => 'You have successfully updated a Service Type status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesServiceType */
|
||||
private $fetchesServiceType;
|
||||
|
||||
/** @var UpdatesServiceTypeStatus */
|
||||
private $updatesServiceTypeStatus;
|
||||
|
||||
/**
|
||||
* UpdateServiceTypeStatusLogic constructor.
|
||||
* @param FetchesServiceType $fetchesServiceType
|
||||
* @param UpdatesServiceTypeStatus $updatesServiceTypeStatus
|
||||
*/
|
||||
public function __construct(FetchesServiceType $fetchesServiceType, UpdatesServiceTypeStatus $updatesServiceTypeStatus)
|
||||
{
|
||||
$this->fetchesServiceType = $fetchesServiceType;
|
||||
$this->updatesServiceTypeStatus = $updatesServiceTypeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
|
||||
$query = $this->fetchesServiceType->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->updatesServiceTypeStatus->execute($query, $request->route('status') === 'active' ? ApprovalStatus::APPROVED : ApprovalStatus::SUSPENDED);
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\ServiceTypes\Services\FetchesServiceCurrenciesConfigurations;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\SegmentConstant;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CustomConfigurationsObject implements DataTransferObject
|
||||
{
|
||||
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $configurations;
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $customOptions;
|
||||
|
||||
/**
|
||||
* CustomConfigurationsObject constructor.
|
||||
* @param SegmentConstant $configurations
|
||||
* @param SegmentConstant $customOptions
|
||||
*/
|
||||
public function __construct(SegmentConstant $configurations, SegmentConstant $customOptions)
|
||||
{
|
||||
$this->configurations = $configurations;
|
||||
$this->customOptions = $customOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SegmentConstant
|
||||
*/
|
||||
public function getConfigurations(): SegmentConstant
|
||||
{
|
||||
return $this->configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SegmentConstant
|
||||
*/
|
||||
public function getCustomOptions(): SegmentConstant
|
||||
{
|
||||
return $this->customOptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfigurationValue(string $name) {
|
||||
return property_exists($this->getCustomOptions()->detail, $name) ?
|
||||
$this->getCustomOptions()->detail->$name: $this->configurations->detail->$name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function calculateServiceCharge(){
|
||||
return ($this->getConfigurationValue('service_charge')->value * 0.01) > $this->getConfigurationValue('minimum_charge')->value ?
|
||||
$this->getConfigurationValue('service_charge')->value : $this->getConfigurationValue('minimum_charge')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function calculateTax(){
|
||||
return $this->getConfigurationValue('tax')->value * 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\Modules\Currencies\DataTransferObjects\RateObject;
|
||||
|
||||
class ServiceCurrenciesObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var boolean */
|
||||
private $isActive;
|
||||
|
||||
/** @var array */
|
||||
private $maxLimit;
|
||||
|
||||
/** @var array */
|
||||
private $minLimit;
|
||||
|
||||
/** @var array */
|
||||
private $rates;
|
||||
|
||||
/**
|
||||
* ServiceCurrenciesObject constructor.
|
||||
* @param int $id
|
||||
* @param bool $isActive
|
||||
* @param array $maxLimit
|
||||
* @param array $minLimit
|
||||
* @param array $rates
|
||||
*/
|
||||
public function __construct(int $id, bool $isActive, array $maxLimit, array $minLimit, array $rates)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->isActive = $isActive;
|
||||
$this->maxLimit = $maxLimit;
|
||||
$this->minLimit = $minLimit;
|
||||
$this->rates = $rates;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMaxLimit(): array
|
||||
{
|
||||
return $this->maxLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getMinLimit(): array
|
||||
{
|
||||
return $this->minLimit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRates(): array
|
||||
{
|
||||
return array_map(function($rate){
|
||||
return new RateObject($rate['selling'], $rate['payment_method']);
|
||||
}, $this->rates);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class ServiceDetailObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
|
||||
/** @var int|null */
|
||||
private $bankId;
|
||||
|
||||
/** @var array|null */
|
||||
private $serviceCharge;
|
||||
|
||||
/** @var array|null */
|
||||
private $minimumCharge;
|
||||
|
||||
/** @var array|null */
|
||||
private $tax;
|
||||
|
||||
/** @var array|null */
|
||||
private $poLimit;
|
||||
|
||||
/** @var array|null */
|
||||
private $currencies;
|
||||
|
||||
/** @var boolean */
|
||||
private $isActive;
|
||||
|
||||
/** @var boolean */
|
||||
private $isBillable;
|
||||
|
||||
/**
|
||||
* ServiceDetailObject constructor.
|
||||
* @param int $id
|
||||
* @param int|null $bankId
|
||||
* @param array|null $serviceCharge
|
||||
* @param array|null $minimumCharge
|
||||
* @param array|null $tax
|
||||
* @param array|null $poLimit
|
||||
* @param array|null $currencies
|
||||
* @param bool $isActive
|
||||
* @param bool $isBillable
|
||||
*/
|
||||
public function __construct(int $id, ?int $bankId, ?array $serviceCharge, ?array $minimumCharge, ?array $tax, ?array $poLimit, ?array $currencies, bool $isActive, bool $isBillable)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->bankId = $bankId;
|
||||
$this->serviceCharge = $serviceCharge;
|
||||
$this->minimumCharge = $minimumCharge;
|
||||
$this->tax = $tax;
|
||||
$this->poLimit = $poLimit;
|
||||
$this->currencies = $currencies;
|
||||
$this->isActive = $isActive;
|
||||
$this->isBillable = $isBillable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getBankId(): ?int
|
||||
{
|
||||
return $this->bankId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getServiceCharge(): ?array
|
||||
{
|
||||
return $this->serviceCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getMinimumCharge(): ?array
|
||||
{
|
||||
return $this->minimumCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getTax(): ?array
|
||||
{
|
||||
return $this->tax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPoLimit(): ?array
|
||||
{
|
||||
return $this->poLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBillable(): bool
|
||||
{
|
||||
return $this->isBillable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurrencies(): ?array
|
||||
{
|
||||
return array_map(function($currency){
|
||||
return new ServiceCurrenciesObject($currency['id'], $currency['active'], $currency['maximum_limit'], $currency['minimum_limit'], $currency['rates']);
|
||||
}, $this->currencies);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class ServiceTypeObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* ServiceTypeObject constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ServiceTypes\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceTypeObject;
|
||||
use App\Models\ServiceType;
|
||||
|
||||
class CreatesServiceType extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
public function execute(ServiceTypeObject $object) {
|
||||
$model = new ServiceType();
|
||||
$model->name = $object->getName();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user