mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'document' into 'master'
Document See merge request CIEFWorldwideSdnBhd/exchange-2.0!3
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class SegmentId implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('segment_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,17 +12,18 @@ use App\Http\Resources\UserResource;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Http\Resources\ContactResource;
|
||||
|
||||
use App\Classes\Modules\CompanyEmployees\Standards\Rules\CanCreateCompanyEmployee;
|
||||
use App\Classes\Modules\CompanyEmployees\Services\CreatesCompanyEmployee;
|
||||
use App\Classes\Modules\CompanyEmployees\DataTransferObjects\CompanyEmployeeObject;
|
||||
use App\Http\Resources\CompanyEmployeeResource;
|
||||
|
||||
use App\Classes\Modules\SegmentCompanies\Standards\Rules\CanCreateSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\Services\CreatesSegmentCompany;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -65,6 +66,12 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
/** @var CreatesCompanyEmployee */
|
||||
private $createsCompanyEmployee;
|
||||
|
||||
/** @var CanCreateSegmentCompany */
|
||||
private $canCreateSegmentCompany;
|
||||
|
||||
/** @var CreatesSegmentCompany */
|
||||
private $createsSegmentCompany;
|
||||
|
||||
/**
|
||||
* CreateUserControllerLogic constructor.
|
||||
* @param CanCreateUser $canCreateUser
|
||||
@@ -75,6 +82,8 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
* @param CreatesContact $createsContact
|
||||
* @param CanCreateCompanyEmployee $canCreateCompanyEmployee
|
||||
* @param CreatesCompanyEmployee $createsCompanyEmployee
|
||||
* @param CanCreateSegmentCompany $canCreateSegmentCompany
|
||||
* @param CreatesSegmentCompany $createsSegmentCompany
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateUser $canCreateUser,
|
||||
@@ -84,7 +93,9 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
CanCreateContact $canCreateContact,
|
||||
CreatesContact $createsContact,
|
||||
CanCreateCompanyEmployee $canCreateCompanyEmployee,
|
||||
CreatesCompanyEmployee $createsCompanyEmployee
|
||||
CreatesCompanyEmployee $createsCompanyEmployee,
|
||||
CanCreateSegmentCompany $canCreateSegmentCompany,
|
||||
CreatesSegmentCompany $createsSegmentCompany
|
||||
)
|
||||
{
|
||||
$this->canCreateUser = $canCreateUser;
|
||||
@@ -95,6 +106,8 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
$this->createsContact = $createsContact;
|
||||
$this->canCreateCompanyEmployee = $canCreateCompanyEmployee;
|
||||
$this->createsCompanyEmployee = $createsCompanyEmployee;
|
||||
$this->canCreateSegmentCompany = $canCreateSegmentCompany;
|
||||
$this->createsSegmentCompany = $createsSegmentCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +153,6 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
$this->canCreateContact->passes($contact_object);
|
||||
$contact_query = $this->createsContact->execute($contact_object);
|
||||
|
||||
|
||||
$company_employee_object = new CompanyEmployeeObject(
|
||||
$company_query->id,
|
||||
$user_query->id
|
||||
@@ -149,11 +161,21 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
$this->canCreateCompanyEmployee->passes($company_employee_object);
|
||||
$company_employee_query = $this->createsCompanyEmployee->execute($user_query, $company_employee_object);
|
||||
|
||||
|
||||
$segment_company_object = new SegmentCompanyObject(
|
||||
1,
|
||||
$company_query->id
|
||||
);
|
||||
|
||||
$this->canCreateSegmentCompany->passes($segment_company_object);
|
||||
$segment_company_query = $this->createsSegmentCompany->execute($company_query, $segment_company_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new UserResource($user_query));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
dd($exception);
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanUpdateDocument;
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ObjectStatus;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ApproveDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Approve Document',
|
||||
'message' => 'You have successfully approved the Document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateDocument */
|
||||
private $canUpdateDocument;
|
||||
|
||||
/** @var ApprovesDocument */
|
||||
private $approvesDocument;
|
||||
|
||||
/** @var FetchesDocument */
|
||||
private $fetchesDocument;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateDocument $canUpdateDocument
|
||||
* @param ApprovesDocument $approvesDocument
|
||||
* @param FetchesDocument $fetchesDocument
|
||||
*/
|
||||
public function __construct(
|
||||
canUpdateDocument $canUpdateDocument,
|
||||
ApprovesDocument $approvesDocument,
|
||||
FetchesDocument $fetchesDocument
|
||||
)
|
||||
{
|
||||
$this->canUpdateDocument = $canUpdateDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
$this->fetchesDocument = $fetchesDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$document_query = $this->fetchesDocument->execute(['id' => $request->route('id')]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
$document_query->owner_id,
|
||||
$document_query->owner_type,
|
||||
$document_query->document_type,
|
||||
$document_query->reference,
|
||||
ObjectStatus::ACTIVE,
|
||||
\Auth::user()->id,
|
||||
$document_query->issued_date,
|
||||
$document_query->expired_date,
|
||||
$document_query->approved_date
|
||||
);
|
||||
$this->canUpdateDocument->passes($document_object);
|
||||
$document_query = $this->approvesDocument->execute($document_query, $document_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
dd($exception);
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Document',
|
||||
'message' => 'You have successfully retrieved a list of Document'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListDocuments */
|
||||
private $canListDocuments;
|
||||
|
||||
/** @var ListsDocuments */
|
||||
private $listsDocuments;
|
||||
|
||||
/**
|
||||
* ListStandardSegmentLogic constructor.
|
||||
* @param CanListDocuments $canListDocuments
|
||||
* @param ListsDocuments $listsDocuments
|
||||
*/
|
||||
public function __construct(CanListDocuments $canListDocuments, ListsDocuments $listsDocuments)
|
||||
{
|
||||
$this->canListDocuments = $canListDocuments;
|
||||
$this->listsDocuments = $listsDocuments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$document_type = $request->input('document_type');
|
||||
$reference = $request->input('reference');
|
||||
$status = $request->input('status');
|
||||
|
||||
$data = [];
|
||||
|
||||
if ($document_type) {
|
||||
$data['document_type'] = $document_type;
|
||||
}
|
||||
if ($reference) {
|
||||
$data['reference'] = $reference;
|
||||
}
|
||||
if ($status) {
|
||||
$data['status'] = $status;
|
||||
}
|
||||
|
||||
$this->canListDocuments->passes();
|
||||
|
||||
$query = $this->listsDocuments->execute($data);
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Models\Document;
|
||||
|
||||
class ApprovesDocument extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Document $model, DocumentObject $object)
|
||||
{
|
||||
$model->status = $object->getStatus();
|
||||
$model->approved_by = $object->getApprovedBy();
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Document;
|
||||
|
||||
class FetchesDocument extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Document */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param Document $repository
|
||||
*/
|
||||
public function __construct(Document $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Document;
|
||||
|
||||
class ListsDocuments extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var Document */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsDocuments constructor.
|
||||
* @param Document $repository
|
||||
*/
|
||||
public function __construct(Document $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class CanListDocuments extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('view document')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\DocumentValidation;
|
||||
|
||||
class CanUpdateDocument extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var DocumentValidation */
|
||||
private $documentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param DocumentValidation $documentValidation
|
||||
*/
|
||||
public function __construct(DocumentValidation $documentValidation)
|
||||
{
|
||||
$this->documentValidation = $documentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->documentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentCompanies\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentCompanyObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var int|null */
|
||||
private $company_id;
|
||||
|
||||
/**
|
||||
* CompanyObject constructor.
|
||||
* @param int|null $segment_id
|
||||
* @param int|null $company_id
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?int $company_id
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->company_id = $company_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCompanyId(): ?int
|
||||
{
|
||||
return $this->company_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentCompanies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class CreatesSegmentCompany extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentCompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, SegmentCompanyObject $object)
|
||||
{
|
||||
$model->segment()->sync($object->getSegmentId());
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentCompanies\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\SegmentCompanyObject;
|
||||
use App\Classes\Modules\SegmentCompanies\Standards\Validators\SegmentCompanyValidation;
|
||||
|
||||
class CanCreateSegmentCompany extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentCompanyValidation */
|
||||
private $segmentCompanyValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param SegmentCompanyValidation $segmentCompanyValidation
|
||||
*/
|
||||
public function __construct(SegmentCompanyValidation $segmentCompanyValidation)
|
||||
{
|
||||
$this->segmentCompanyValidation = $segmentCompanyValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentCompanyValidation $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentCompanyValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentCompanyValidation $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentCompanies\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\SegmentCompanies\DataTransferObjects\CompanyEmployeeObject;
|
||||
|
||||
class SegmentCompanyValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param CompanyEmployeeObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'segment_id' => $object->getSegmentId(),
|
||||
'company_id' => $object->getCompanyId(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'segment_id' => 'required',
|
||||
'company_id' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanCreateSegmentConstant;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantTax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantBillingFee;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantServiceCharge;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantBookingAmountMax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\CreatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
|
||||
|
||||
use App\Http\Resources\SegmentConstantResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateSegmentConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Segment Constant',
|
||||
'message' => 'You have successfully created a new Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateSegmentConstant */
|
||||
private $canCreateSegmentConstant;
|
||||
|
||||
/** @var CreatesSegmentConstantTax */
|
||||
private $createsSegmentConstantTax;
|
||||
|
||||
/** @var CreatesSegmentConstantBillingFee */
|
||||
private $createsSegmentConstantBillingFee;
|
||||
|
||||
/** @var CreatesSegmentConstantServiceCharge */
|
||||
private $createsSegmentConstantServiceCharge;
|
||||
|
||||
/** @var CreatesSegmentConstantBookingAmountMax */
|
||||
private $createsSegmentConstantBookingAmountMax;
|
||||
|
||||
/** @var CreatesSegmentConstantPaymentAttemptExpiryTime */
|
||||
private $createsSegmentConstantPaymentAttemptExpiryTime;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* CreateSegmentConstantLogic constructor.
|
||||
* @param CanCreateSegmentConstant $canCreateSegmentConstant
|
||||
* @param CreatesSegmentConstantTax $createsSegmentConstantTax
|
||||
* @param CreatesSegmentConstantBillingFee $createsSegmentConstantBillingFee
|
||||
* @param CreatesSegmentConstantServiceCharge $createsSegmentConstantServiceCharge
|
||||
* @param CreatesSegmentConstantBookingAmountMax $createsSegmentConstantBookingAmountMax
|
||||
* @param CreatesSegmentConstantPaymentAttemptExpiryTime $createsSegmentConstantPaymentAttemptExpiryTime
|
||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
||||
* @param FetchesSegment $fetchesSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateSegmentConstant $canCreateSegmentConstant,
|
||||
CreatesSegmentConstantTax $createsSegmentConstantTax,
|
||||
CreatesSegmentConstantBillingFee $createsSegmentConstantBillingFee,
|
||||
CreatesSegmentConstantServiceCharge $createsSegmentConstantServiceCharge,
|
||||
CreatesSegmentConstantBookingAmountMax $createsSegmentConstantBookingAmountMax,
|
||||
CreatesSegmentConstantPaymentAttemptExpiryTime $createsSegmentConstantPaymentAttemptExpiryTime,
|
||||
FetchesSegmentConstant $fetchesSegmentConstant,
|
||||
FetchesSegment $fetchesSegment
|
||||
)
|
||||
{
|
||||
$this->canCreateSegmentConstant = $canCreateSegmentConstant;
|
||||
$this->createsSegmentConstantTax = $createsSegmentConstantTax;
|
||||
$this->createsSegmentConstantBillingFee = $createsSegmentConstantBillingFee;
|
||||
$this->createsSegmentConstantServiceCharge = $createsSegmentConstantServiceCharge;
|
||||
$this->createsSegmentConstantBookingAmountMax = $createsSegmentConstantBookingAmountMax;
|
||||
$this->createsSegmentConstantPaymentAttemptExpiryTime = $createsSegmentConstantPaymentAttemptExpiryTime;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
$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->input('segment_id'),
|
||||
]);
|
||||
|
||||
$segment_constant_query = $this->fetchesSegmentConstant->execute([
|
||||
'id' => $request->input('standard_segment_constant_id'),
|
||||
]);
|
||||
|
||||
if ($segment_constant_query->reference == 'TAX') {
|
||||
$segment_constant_object = new SegmentConstantTaxObject(
|
||||
$request->input('segment_id'),
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
|
||||
$this->canCreateSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->createsSegmentConstantTax->execute($segment_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
|
||||
$segment_constant_object = new SegmentConstantBillingFeeObject(
|
||||
$request->input('segment_id'),
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canCreateSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->createsSegmentConstantBillingFee->execute($segment_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
|
||||
$segment_constant_object = new SegmentConstantServiceChargeObject(
|
||||
$request->input('segment_id'),
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canCreateSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->createsSegmentConstantServiceCharge->execute($segment_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
|
||||
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
|
||||
$request->input('segment_id'),
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value'),
|
||||
$segment_constant_query->detail->currency_id
|
||||
);
|
||||
$this->canCreateSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->createsSegmentConstantBookingAmountMax->execute($segment_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
||||
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
|
||||
$request->input('segment_id'),
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canCreateSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->createsSegmentConstantPaymentAttemptExpiryTime->execute($segment_query, $segment_constant_object);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentConstantResource($segment_constant_query));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\SegmentConstants\Services\ListsSegmentConstants;
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanListStandardSegmentConstants;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStandardSegmentConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Standard Segment Constant',
|
||||
'message' => 'You have successfully retrieved a list of Standard Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListStandardSegmentConstants */
|
||||
private $canListStandardSegmentConstants;
|
||||
|
||||
/** @var ListsSegmentConstants */
|
||||
private $listsSegmentConstants;
|
||||
|
||||
/**
|
||||
* ListStandardSegmentConstantLogic constructor.
|
||||
* @param CanListStandardSegmentConstants $canListStandardSegmentConstants
|
||||
* @param ListsSegmentConstants $listsSegmentConstants
|
||||
*/
|
||||
public function __construct(CanListStandardSegmentConstants $canListStandardSegmentConstants, ListsSegmentConstants $listsSegmentConstants)
|
||||
{
|
||||
$this->canListStandardSegmentConstants = $canListStandardSegmentConstants;
|
||||
$this->listsSegmentConstants = $listsSegmentConstants;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canListStandardSegmentConstants->passes();
|
||||
|
||||
$query = $this->listsSegmentConstants->execute(
|
||||
[
|
||||
'segment_id' => 1
|
||||
]
|
||||
);
|
||||
|
||||
return $this->collectionResponse(SegmentResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateStandardSegmentConstant;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantTax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBillingFee;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantServiceCharge;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBookingAmountMax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
|
||||
|
||||
use App\Http\Resources\SegmentConstantResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateSegmentConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Segment Constant',
|
||||
'message' => 'You have successfully updated the Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateStandardSegmentConstant */
|
||||
private $canUpdateStandardSegmentConstant;
|
||||
|
||||
/** @var UpdatesSegmentConstantTax */
|
||||
private $updatesSegmentConstantTax;
|
||||
|
||||
/** @var UpdatesSegmentConstantBillingFee */
|
||||
private $updatesSegmentConstantBillingFee;
|
||||
|
||||
/** @var UpdatesSegmentConstantServiceCharge */
|
||||
private $updatesSegmentConstantServiceCharge;
|
||||
|
||||
/** @var UpdatesSegmentConstantBookingAmountMax */
|
||||
private $updatesSegmentConstantBookingAmountMax;
|
||||
|
||||
/** @var UpdatesSegmentConstantPaymentAttemptExpiryTime */
|
||||
private $updatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant
|
||||
* @param UpdatesSegmentConstantTax $updatesSegmentConstantTax
|
||||
* @param UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee
|
||||
* @param UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge
|
||||
* @param UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax
|
||||
* @param UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime
|
||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant,
|
||||
UpdatesSegmentConstantTax $updatesSegmentConstantTax,
|
||||
UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee,
|
||||
UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge,
|
||||
UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax,
|
||||
UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime,
|
||||
FetchesSegmentConstant $fetchesSegmentConstant
|
||||
)
|
||||
{
|
||||
$this->canUpdateStandardSegmentConstant = $canUpdateStandardSegmentConstant;
|
||||
$this->updatesSegmentConstantTax = $updatesSegmentConstantTax;
|
||||
$this->updatesSegmentConstantBillingFee = $updatesSegmentConstantBillingFee;
|
||||
$this->updatesSegmentConstantServiceCharge = $updatesSegmentConstantServiceCharge;
|
||||
$this->updatesSegmentConstantBookingAmountMax = $updatesSegmentConstantBookingAmountMax;
|
||||
$this->updatesSegmentConstantPaymentAttemptExpiryTime = $updatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_constant_query = $this->fetchesSegmentConstant->execute(['id' => $request->route('id')]);
|
||||
|
||||
if ($segment_constant_query->reference == 'TAX') {
|
||||
$segment_constant_object = new SegmentConstantTaxObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantTax->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
|
||||
$segment_constant_object = new SegmentConstantBillingFeeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantBillingFee->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
|
||||
$segment_constant_object = new SegmentConstantServiceChargeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantServiceCharge->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
|
||||
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value'),
|
||||
$segment_constant_query->detail->currency_id
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantBookingAmountMax->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
||||
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantPaymentAttemptExpiryTime->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentConstantResource($segment_constant_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\FetchesSegmentConstant;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Rules\CanUpdateStandardSegmentConstant;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantTax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBillingFee;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantServiceCharge;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantBookingAmountMax;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\Services\UpdatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
|
||||
|
||||
use App\Http\Resources\SegmentConstantResource;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateStandardSegmentConstantLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Standard Segment Constant',
|
||||
'message' => 'You have successfully updated the Standard Segment Constant'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanUpdateStandardSegmentConstant */
|
||||
private $canUpdateStandardSegmentConstant;
|
||||
|
||||
/** @var UpdatesSegmentConstantTax */
|
||||
private $updatesSegmentConstantTax;
|
||||
|
||||
/** @var UpdatesSegmentConstantBillingFee */
|
||||
private $updatesSegmentConstantBillingFee;
|
||||
|
||||
/** @var UpdatesSegmentConstantServiceCharge */
|
||||
private $updatesSegmentConstantServiceCharge;
|
||||
|
||||
/** @var UpdatesSegmentConstantBookingAmountMax */
|
||||
private $updatesSegmentConstantBookingAmountMax;
|
||||
|
||||
/** @var UpdatesSegmentConstantPaymentAttemptExpiryTime */
|
||||
private $updatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant
|
||||
* @param UpdatesSegmentConstantTax $updatesSegmentConstantTax
|
||||
* @param UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee
|
||||
* @param UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge
|
||||
* @param UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax
|
||||
* @param UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime
|
||||
* @param FetchesSegmentConstant $fetchesSegmentConstant
|
||||
*/
|
||||
public function __construct(
|
||||
CanUpdateStandardSegmentConstant $canUpdateStandardSegmentConstant,
|
||||
UpdatesSegmentConstantTax $updatesSegmentConstantTax,
|
||||
UpdatesSegmentConstantBillingFee $updatesSegmentConstantBillingFee,
|
||||
UpdatesSegmentConstantServiceCharge $updatesSegmentConstantServiceCharge,
|
||||
UpdatesSegmentConstantBookingAmountMax $updatesSegmentConstantBookingAmountMax,
|
||||
UpdatesSegmentConstantPaymentAttemptExpiryTime $updatesSegmentConstantPaymentAttemptExpiryTime,
|
||||
FetchesSegmentConstant $fetchesSegmentConstant
|
||||
)
|
||||
{
|
||||
$this->canUpdateStandardSegmentConstant = $canUpdateStandardSegmentConstant;
|
||||
$this->updatesSegmentConstantTax = $updatesSegmentConstantTax;
|
||||
$this->updatesSegmentConstantBillingFee = $updatesSegmentConstantBillingFee;
|
||||
$this->updatesSegmentConstantServiceCharge = $updatesSegmentConstantServiceCharge;
|
||||
$this->updatesSegmentConstantBookingAmountMax = $updatesSegmentConstantBookingAmountMax;
|
||||
$this->updatesSegmentConstantPaymentAttemptExpiryTime = $updatesSegmentConstantPaymentAttemptExpiryTime;
|
||||
$this->fetchesSegmentConstant = $fetchesSegmentConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_constant_query = $this->fetchesSegmentConstant->execute(['id' => $request->route('id')]);
|
||||
|
||||
if ($segment_constant_query->reference == 'TAX') {
|
||||
$segment_constant_object = new SegmentConstantTaxObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantTax->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BILLING_FEE') {
|
||||
$segment_constant_object = new SegmentConstantBillingFeeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantBillingFee->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'SERVICE_CHARGE') {
|
||||
$segment_constant_object = new SegmentConstantServiceChargeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantServiceCharge->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'BOOKING_AMOUNT_MAX') {
|
||||
$segment_constant_object = new SegmentConstantBookingAmountMaxObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value'),
|
||||
$segment_constant_query->detail->currency_id
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantBookingAmountMax->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
elseif ($segment_constant_query->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
||||
$segment_constant_object = new SegmentConstantPaymentAttemptExpiryTimeObject(
|
||||
$segment_constant_query->segment_id,
|
||||
$segment_constant_query->name,
|
||||
$segment_constant_query->reference,
|
||||
$segment_constant_query->detail->type,
|
||||
$request->input('value')
|
||||
);
|
||||
$this->canUpdateStandardSegmentConstant->passes($segment_constant_object);
|
||||
$segment_constant_query = $this->updatesSegmentConstantPaymentAttemptExpiryTime->execute($segment_constant_query, $segment_constant_object);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentConstantResource($segment_constant_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentConstantBillingFeeObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* SegmentConstantObject constructor.
|
||||
* @param string|null $segment_id
|
||||
* @param string|null $name
|
||||
* @param string|null $reference
|
||||
* @param string|null $type
|
||||
* @param int|null $value
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?string $name,
|
||||
?string $reference,
|
||||
?string $type,
|
||||
?int $value
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->name = $name;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue(): ?int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentConstantBookingAmountMaxObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/** @var int */
|
||||
private $currency_id;
|
||||
|
||||
/**
|
||||
* SegmentConstantObject constructor.
|
||||
* @param string|null $segment_id
|
||||
* @param string|null $name
|
||||
* @param string|null $reference
|
||||
* @param string|null $type
|
||||
* @param int|null $value
|
||||
* @param int|null $currency_id
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?string $name,
|
||||
?string $reference,
|
||||
?string $type,
|
||||
?int $value,
|
||||
?int $currency_id
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->name = $name;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
$this->currency_id = $currency_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue(): ?int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrencyId(): ?int
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentConstantPaymentAttemptExpiryTimeObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* SegmentConstantObject constructor.
|
||||
* @param string|null $segment_id
|
||||
* @param string|null $name
|
||||
* @param string|null $reference
|
||||
* @param string|null $type
|
||||
* @param int|null $value
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?string $name,
|
||||
?string $reference,
|
||||
?string $type,
|
||||
?int $value
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->name = $name;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue(): ?int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentConstantServiceChargeObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* SegmentConstantObject constructor.
|
||||
* @param string|null $segment_id
|
||||
* @param string|null $name
|
||||
* @param string|null $reference
|
||||
* @param string|null $type
|
||||
* @param int|null $value
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?string $name,
|
||||
?string $reference,
|
||||
?string $type,
|
||||
?int $value
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->name = $name;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue(): ?int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentConstantTaxObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $segment_id;
|
||||
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/** @var int */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* SegmentConstantObject constructor.
|
||||
* @param string|null $segment_id
|
||||
* @param string|null $name
|
||||
* @param string|null $reference
|
||||
* @param string|null $type
|
||||
* @param int|null $value
|
||||
*/
|
||||
public function __construct(
|
||||
?int $segment_id,
|
||||
?string $name,
|
||||
?string $reference,
|
||||
?string $type,
|
||||
?int $value
|
||||
)
|
||||
{
|
||||
$this->segment_id = $segment_id;
|
||||
$this->name = $name;
|
||||
$this->reference = $reference;
|
||||
$this->type = $type;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSegmentId(): ?int
|
||||
{
|
||||
return $this->segment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getValue(): ?int
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegmentConstantBillingFee extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantBillingFeeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $segment, SegmentConstantBillingFeeObject $object)
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->segment_id = $segment->id;
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegmentConstantBookingAmountMax extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantBookingAmountMaxObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $segment, SegmentConstantBookingAmountMaxObject $object)
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->segment_id = $segment->id;
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue(),
|
||||
'currency_id' => $object->getCurrencyId()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttempExpiryTimeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegmentConstantPaymentAttemptExpiryTime extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantPaymentAttempExpiryTimeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $segment, SegmentConstantPaymentAttempExpiryTimeObject $object)
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->segment_id = $object->getSegmentId();
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue(),
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegmentConstantServiceCharge extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantServiceChargeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $segment, SegmentConstantServiceChargeObject $object)
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->segment_id = $object->getSegmentId();
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
||||
use App\Models\SegmentConstant;
|
||||
use App\Models\Segment;
|
||||
|
||||
class CreatesSegmentConstantTax extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantTaxObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Segment $segment, SegmentConstantTaxObject $object)
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->segment_id = $object->getSegmentId();
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class FetchesSegmentConstant extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesSegmentConstant constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class ListsSegmentConstants extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var SegmentConstant */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ListsSegmentConstants constructor.
|
||||
* @param SegmentConstant $repository
|
||||
*/
|
||||
public function __construct(SegmentConstant $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBillingFeeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesSegmentConstantBillingFee extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstantBillingFeeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, SegmentConstantBillingFeeObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantBookingAmountMaxObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesSegmentConstantBookingAmountMax extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstantBookingAmountMaxObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, SegmentConstantBookingAmountMaxObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue(),
|
||||
'currency_id' => $object->getCurrencyId(),
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantPaymentAttemptExpiryTimeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesSegmentConstantPaymentAttemptExpiryTime extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstantPaymentAttemptExpiryTimeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, SegmentConstantPaymentAttemptExpiryTimeObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantServiceChargeObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesSegmentConstantServiceCharge extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstantServiceChargeObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, SegmentConstantServiceChargeObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantTaxObject;
|
||||
use App\Models\SegmentConstant;
|
||||
|
||||
class UpdatesSegmentConstantTax extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param SegmentConstantTaxObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentConstant $model, SegmentConstantTaxObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->detail = json_encode([
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
]);
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentObject;
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Validators\SegmentConstantValidation;
|
||||
|
||||
class CanCreateSegmentConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentConstantValidation */
|
||||
private $segmentConstantValidation;
|
||||
|
||||
/**
|
||||
* CanCreateSegmentConstant constructor.
|
||||
* @param SegmentConstantValidation $segmentConstantValidation
|
||||
*/
|
||||
public function __construct(SegmentConstantValidation $segmentConstantValidation)
|
||||
{
|
||||
$this->segmentConstantValidation = $segmentConstantValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!\Auth::user()->can('add segment_constant')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentConstantValidation->validate($object, 'POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanListStandardSegmentConstants extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('view standard_segment_constant')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentCompanyObject;
|
||||
use App\Classes\Modules\SegmentConstants\Standards\Validators\SegmentConstantValidation;
|
||||
|
||||
class CanUpdateStandardSegmentConstant extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentConstantValidation */
|
||||
private $segmentConstantValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param SegmentConstantValidation $segmentConstantValidation
|
||||
*/
|
||||
public function __construct(SegmentConstantValidation $segmentConstantValidation)
|
||||
{
|
||||
$this->segmentConstantValidation = $segmentConstantValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('view standard_segment_constant')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentConstantValidation $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentConstantValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentConstantValidation $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\SegmentConstants\Standards\Validators;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentConstantObject;
|
||||
|
||||
class SegmentConstantValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param SegmentConstantObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
|
||||
$this->reference = $object->getReference();
|
||||
if ($this->reference == 'TAX') {
|
||||
return [
|
||||
'segment_id'=> $object->getSegmentId(),
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'BILLING_FEE') {
|
||||
return [
|
||||
'segment_id' => $object->getSegmentId(),
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'SERVICE_CHARGE') {
|
||||
return [
|
||||
'segment_id' => $object->getSegmentId(),
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'BOOKING_AMOUNT_MAX') {
|
||||
return [
|
||||
'segment_id' => $object->getSegmentId(),
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue(),
|
||||
'currency_id' => $object->getCurrencyId()
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
||||
return [
|
||||
'segment_id' => $object->getSegmentId(),
|
||||
'name' => $object->getName(),
|
||||
'reference' => $object->getReference(),
|
||||
'type' => $object->getType(),
|
||||
'value' => $object->getValue()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(?string $type = 'POST'): array {
|
||||
|
||||
if ($this->reference == 'TAX') {
|
||||
return [
|
||||
'segment_id' => $type == 'POST' ? 'required' : '',
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'type' => 'required',
|
||||
'value' => 'required'
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'BILLING_FEE') {
|
||||
return [
|
||||
'segment_id' => $type == 'POST' ? 'required' : '',
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'type' => 'required',
|
||||
'value' => 'required'
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'SERVICE_CHARGE') {
|
||||
return [
|
||||
'segment_id' => $type == 'POST' ? 'required' : '',
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'type' => 'required',
|
||||
'value' => 'required'
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'BOOKING_AMOUNT_MAX') {
|
||||
return [
|
||||
'segment_id' => $type == 'POST' ? 'required' : '',
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'type' => 'required',
|
||||
'value' => 'required',
|
||||
'currency_id' => 'required'
|
||||
];
|
||||
}
|
||||
elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') {
|
||||
return [
|
||||
'segment_id' => $type == 'POST' ? 'required' : '',
|
||||
'name' => 'required',
|
||||
'reference' => 'required',
|
||||
'type' => 'required',
|
||||
'value' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
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 ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Segment',
|
||||
'message' => 'You have successfully created a new Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateSegment */
|
||||
private $canCreateSegment;
|
||||
|
||||
/** @var CreatesSegment */
|
||||
private $createsSegment;
|
||||
|
||||
/**
|
||||
* CreateSegmentLogic constructor.
|
||||
* @param CanCreateSegment $canCreateSegment
|
||||
* @param CreatesSegment $createsSegment
|
||||
*/
|
||||
public function __construct(
|
||||
CanCreateSegment $canCreateSegment,
|
||||
CreatesSegment $createsSegment
|
||||
)
|
||||
{
|
||||
$this->canCreateSegment = $canCreateSegment;
|
||||
$this->createsSegment = $createsSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_object = new SegmentObject(
|
||||
$request->input('name')
|
||||
);
|
||||
|
||||
$this->canCreateSegment->passes($segment_object);
|
||||
$segment_query = $this->createsSegment->execute($segment_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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\CanDeleteSegment;
|
||||
use App\Classes\Modules\Segments\Services\DeletesSegment;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DeleteSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Delete Segment',
|
||||
'message' => 'You have successfully deleted the Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanDeleteSegment */
|
||||
private $canDeleteSegment;
|
||||
|
||||
/** @var DeletesSegment */
|
||||
private $deletesSegment;
|
||||
|
||||
/** @var FetchesSegment */
|
||||
private $fetchesSegment;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic constructor.
|
||||
* @param CanUpdateSegment $canDeleteSegment
|
||||
* @param UpdatesSegment $deletesSegment
|
||||
* @param 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
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$segment_query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
||||
$this->canDeleteSegment->passes();
|
||||
$this->deletesSegment->execute($segment_query);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new SegmentResource($segment_query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
dd($exception);
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\ListsSegments;
|
||||
use App\Classes\Modules\Segments\Standards\Rules\CanListStandardSegments;
|
||||
use App\Http\Resources\SegmentResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStandardSegmentLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Segment',
|
||||
'message' => 'You have successfully retrieved a list of Segment'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanListStandardSegments */
|
||||
private $canListStandardSegments;
|
||||
|
||||
/** @var ListsSegments */
|
||||
private $listsSegments;
|
||||
|
||||
/**
|
||||
* ListStandardSegmentLogic constructor.
|
||||
* @param CanListStandardSegments $canListStandardSegments
|
||||
* @param ListsSegments $listsSegments
|
||||
*/
|
||||
public function __construct(CanListStandardSegments $canListStandardSegments, ListsSegments $listsSegments)
|
||||
{
|
||||
$this->canListStandardSegments = $canListStandardSegments;
|
||||
$this->listsSegments = $listsSegments;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->canListStandardSegments->passes();
|
||||
|
||||
$query = $this->listsSegments->execute(['id' => 1]);
|
||||
|
||||
return $this->collectionResponse(SegmentResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* UpdateStandardSegmentConstantLogic 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class SegmentObject implements DataTransferObject
|
||||
{
|
||||
/** @var string|null */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* SegmentObject constructor.
|
||||
* @param string|null $name
|
||||
*/
|
||||
public function __construct(
|
||||
?string $name
|
||||
)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
@@ -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 CreatesSegment extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(SegmentObject $object) {
|
||||
$model = new Segment();
|
||||
$model->name = $object->getName();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||
use App\Models\Segment;
|
||||
|
||||
class DeletesSegment extends AbstractDeleteRecord
|
||||
{
|
||||
|
||||
public function execute(Segment $model) {
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\Segment;
|
||||
|
||||
class FetchesSegment extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var Segment */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param Segment $repository
|
||||
*/
|
||||
public function __construct(Segment $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public 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,22 @@
|
||||
<?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 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,55 @@
|
||||
<?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 CanCreateSegment extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var SegmentValidation */
|
||||
private $segmentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateSegment 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('add 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,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanDeleteSegment extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('delete segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class CanListStandardSegments extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
if (!\Auth::user()->can('view standard_segment')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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,58 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* CanCreateAddress 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 SegmentValidation $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->segmentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SegmentValidation $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
||||
|
||||
class SegmentValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param SegmentObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'name' => $object->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,6 @@
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class ObjectStatus {
|
||||
public const ACTIVE = 1;
|
||||
public const PENDING = 9;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Documents;
|
||||
|
||||
use App\Classes\Modules\Documents\ControllersLogic\ApproveDocumentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ApproveDocumentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ApproveDocumentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function approve(Request $request, ApproveDocumentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Documents;
|
||||
|
||||
use App\Classes\Modules\Documents\ControllersLogic\ListDocumentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListDocumentsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListDocumentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListDocumentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SegmentConstants;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\ControllersLogic\CreateSegmentConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateSegmentConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateSegmentConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateSegmentConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\SegmentConstants;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\ControllersLogic\UpdateSegmentConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateSegmentConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateSegmentConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateSegmentConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\CreateSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\DeleteSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param DeleteSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeleteSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\UpdateSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateSegmentController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\StandardSegmentConstants;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\ControllersLogic\ListStandardSegmentConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStandardSegmentConstantsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListStandardSegmentConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListStandardSegmentConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\StandardSegmentConstants;
|
||||
|
||||
use App\Classes\Modules\SegmentConstants\ControllersLogic\UpdateStandardSegmentConstantLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateStandardSegmentConstantController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateStandardSegmentConstantLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateStandardSegmentConstantLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\StandardSegments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\ListStandardSegmentLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListStandardSegmentsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListStandardSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListStandardSegmentLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DocumentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'document_type' => $this->document_type,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'approved_by' => (int) $this->approved_by,
|
||||
'files' => $this->files()->get()
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SegmentConstantResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'detail' => $this->detail
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class SegmentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -24,6 +25,14 @@ class Company extends AbstractModel
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return belongsToMany
|
||||
*/
|
||||
public function segment(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Segment::class, 'segment_company', 'company_id', 'segment_id');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-1
@@ -5,6 +5,8 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package App\Models
|
||||
@@ -22,5 +24,18 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
//
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'documents';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return hasMany
|
||||
*/
|
||||
public function files(): hasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'document_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,9 @@ class File extends AbstractModel
|
||||
protected $table = 'files';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getFileAttribute($value)
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class Permission extends AbstractModel
|
||||
{
|
||||
protected $table = 'permissions';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Spatie\Permission\Models\Role as SpatieRole;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class Role extends AbstractModel
|
||||
{
|
||||
protected $table = 'roles';
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Segment
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property string name
|
||||
* @property string reference
|
||||
*/
|
||||
class Segment extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'segments';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class SegmentCompany
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Segment segment_id
|
||||
* @property \App\Models\CPmpany company_id
|
||||
*/
|
||||
class SegmentCompany extends AbstractModel
|
||||
{
|
||||
protected $table = 'segment_company';
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class SegmentConstant
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Segment segment_id
|
||||
* @property text detail
|
||||
*/
|
||||
class SegmentConstant extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'segment_constants';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getDetailAttribute($value)
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
}
|
||||
|
||||
}
|
||||
+4
-10
@@ -4,6 +4,9 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
@@ -20,7 +23,7 @@ class User extends AbstractModel implements
|
||||
AuthorizableContract,
|
||||
CanResetPasswordContract
|
||||
{
|
||||
use Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
|
||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,15 +57,6 @@ class User extends AbstractModel implements
|
||||
return $this->hasMany(PasswordReset::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
// public function employers(): belongsToMany {
|
||||
// return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_id');
|
||||
// }
|
||||
|
||||
// public function tweets(): hasMany {
|
||||
// return $this->hasMany(Order::class, 'user_id', 'id');
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @return belongsToMany
|
||||
*/
|
||||
|
||||
@@ -20,8 +20,8 @@ class CreateDocumentsTable extends Migration
|
||||
$table->string('document_type')->nullable();
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->bigInteger('approved_by')->unsigned();
|
||||
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade')->nullable();
|
||||
$table->bigInteger('approved_by')->unsigned()->nullable();
|
||||
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->timestamp('issued_date')->nullable();
|
||||
$table->timestamp('expired_date')->nullable();
|
||||
$table->timestamp('approved_date')->nullable();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSegmentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('segments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('segments');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSegmentConstantsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('segment_constants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('segment_id')->unsigned()->nullable();
|
||||
$table->foreign('segment_id')->references('id')->on('segments')->onDelete('cascade');
|
||||
$table->string('name')->nullable();
|
||||
$table->string('reference')->nullable();
|
||||
$table->text('detail')->nullable();
|
||||
$table->timestamps();
|
||||
$table->integer('type')->nullable();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('segment_constants');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSegmentCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('segment_company', function (Blueprint $table) {
|
||||
$table->bigInteger('segment_id')->unsigned();
|
||||
$table->foreign('segment_id')->references('id')->on('segments')->onDelete('cascade');
|
||||
$table->bigInteger('company_id')->unsigned();
|
||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||
$table->primary(['segment_id', 'company_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('segment_company');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class AdminUserPermissionsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Reset cached roles and permissions
|
||||
app()['cache']->forget('spatie.permission.cache');
|
||||
|
||||
// admin permissions
|
||||
Permission::create(['name' => 'view document', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add document', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit document', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete document', 'guard_name' => 'web']);
|
||||
|
||||
|
||||
Permission::create(['name' => 'view standard_segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add standard_segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit standard_segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete standard_segment', 'guard_name' => 'web']);
|
||||
|
||||
Permission::create(['name' => 'view standard_segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add standard_segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit standard_segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete standard_segment_constant', 'guard_name' => 'web']);
|
||||
|
||||
Permission::create(['name' => 'view segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit segment', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete segment', 'guard_name' => 'web']);
|
||||
|
||||
Permission::create(['name' => 'view segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'add segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'edit segment_constant', 'guard_name' => 'web']);
|
||||
Permission::create(['name' => 'delete segment_constant', 'guard_name' => 'web']);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$shadow_admin_role = Role::create([
|
||||
'name' => 'Shadow Admin',
|
||||
'guard_name' => 'web',
|
||||
'type' => 1,
|
||||
]);
|
||||
|
||||
$shadow_admin_role->givePermissionTo(Permission::all());
|
||||
|
||||
$admin = User::find(1);
|
||||
$admin->assignRole($shadow_admin_role);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$ultimate_admin_role = Role::create([
|
||||
'name' => 'Ultimate Admin',
|
||||
'guard_name' => 'web',
|
||||
'type' => 1,
|
||||
]);
|
||||
|
||||
$ultimate_admin_role->givePermissionTo(Permission::all());
|
||||
|
||||
$admin = User::find(2);
|
||||
$admin->assignRole($ultimate_admin_role);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AdminUserTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'The One',
|
||||
'email' => 'admin@exchange.com',
|
||||
'password' => bcrypt('pass123'),
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'remember_token' => (string) Str::uuid(),
|
||||
'active_at' => date('Y-m-d H:i:s'),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'The Admin',
|
||||
'email' => 'admin2@exchange.com',
|
||||
'password' => bcrypt('pass123'),
|
||||
'type' => 1,
|
||||
'status' => 1,
|
||||
'remember_token' => (string) Str::uuid(),
|
||||
'active_at' => date('Y-m-d H:i:s'),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,13 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(StatesTableSeeder::class);
|
||||
$this->call(DistrictsTableSeeder::class);
|
||||
|
||||
$this->call(SegmentsTableSeeder::class);
|
||||
$this->call(SegmentConstantsTableSeeder::class);
|
||||
|
||||
// Admin
|
||||
$this->call(AdminUserTableSeeder::class);
|
||||
$this->call(AdminUserPermissionsTableSeeder::class);
|
||||
|
||||
DB::commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SegmentConstantsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('segment_constants')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'segment_id' => 1,
|
||||
'name' => 'Tax',
|
||||
'reference' => 'TAX',
|
||||
'detail' => json_encode([
|
||||
'type' => 'percentage',
|
||||
'value' => '10'
|
||||
]),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'segment_id' => 1,
|
||||
'name' => 'Billing Fee',
|
||||
'reference' => 'BILLING_FEE',
|
||||
'detail' => json_encode([
|
||||
'type' => 'fix_rate',
|
||||
'value' => '10'
|
||||
]),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'segment_id' => 1,
|
||||
'name' => 'Service Charge',
|
||||
'reference' => 'SERVICE_CHARGE',
|
||||
'detail' => json_encode([
|
||||
'type' => 'fix_rate',
|
||||
'value' => '10'
|
||||
]),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'segment_id' => 1,
|
||||
'name' => 'Booking Amount Max',
|
||||
'reference' => 'BOOKING_AMOUNT_MAX',
|
||||
'detail' => json_encode([
|
||||
'type' => 'fix_rate',
|
||||
'value' => '10',
|
||||
'currency_id' => 1
|
||||
]),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'segment_id' => 1,
|
||||
'name' => 'Payment Attempt Expiry Time',
|
||||
'reference' => 'PAYMENT_ATTEMP_EXPIRY_TIME',
|
||||
'detail' => json_encode([
|
||||
'type' => 'day',
|
||||
'value' => '10',
|
||||
]),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SegmentsTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('segments')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'Standard Segment',
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -79,12 +79,15 @@
|
||||
methods:{
|
||||
successHandler(response){
|
||||
localStorage.setItem('user-token', response.payload.access_token);
|
||||
|
||||
console.log(response.payload.access_token);
|
||||
|
||||
this.$store.dispatch('userAuthentication', {access_token: response.payload.access_token});
|
||||
this.error = '';
|
||||
this.$store.dispatch('toggleSection', {name: 'loginSuccess', status: true})
|
||||
setTimeout(function(){
|
||||
window.location.href = response.payload.redirect_url;
|
||||
}, 2000);
|
||||
// this.$store.dispatch('toggleSection', {name: 'loginSuccess', status: true})
|
||||
// setTimeout(function(){
|
||||
// window.location.href = response.payload.redirect_url;
|
||||
// }, 2000);
|
||||
},
|
||||
errorHandler(error){
|
||||
this.$store.dispatch('userAuthentication', {access_token: ''});
|
||||
|
||||
@@ -18,6 +18,12 @@ Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function
|
||||
|
||||
require __DIR__ . '/account.php';
|
||||
|
||||
require __DIR__ . '/document.php';
|
||||
|
||||
require __DIR__ . '/segment.php';
|
||||
require __DIR__ . '/segment_constant.php';
|
||||
|
||||
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
require __DIR__ . '/crud.php';
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['namespace' => 'Documents'], function () {
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::group(['prefix' => 'document'], function () {
|
||||
Route::get('/list', 'ListDocumentsController@list')->name('document.list');
|
||||
Route::put('/approve/{id}', 'ApproveDocumentController@approve')->name('document.approve');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['namespace' => 'StandardSegments'], function () {
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::group(['prefix' => 'standard-segment'], function () {
|
||||
Route::get('/list', 'ListStandardSegmentsController@list')->name('standard_segment.update');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Route::group(['namespace' => 'Segments'], function () {
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::group(['prefix' => 'segment'], function () {
|
||||
Route::post('/create', 'CreateSegmentController@create')->name('segment.create');
|
||||
Route::put('/update/{id}', 'UpdateSegmentController@update')->name('segment.update');
|
||||
Route::delete('/delete/{id}', 'DeleteSegmentController@delete')->name('segment.delete');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['namespace' => 'StandardSegmentConstants'], function () {
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::group(['prefix' => 'standard-segment-constant'], function () {
|
||||
Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
|
||||
Route::put('/update/{id}', 'UpdateStandardSegmentConstantController@update')->name('standard_segment_constant.update');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Route::group(['namespace' => 'SegmentConstants'], function () {
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::group(['prefix' => 'segment-constant'], function () {
|
||||
// Route::get('/list', 'ListStandardSegmentConstantsController@list')->name('standard_segment.update');
|
||||
Route::post('/create', 'CreateSegmentConstantController@create')->name('segment_constant.create');
|
||||
Route::put('/update/{id}', 'UpdateSegmentConstantController@update')->name('segment_constant.update');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user