From 1fbdc795ff3d8b99a84f2a5af4aa1c02d5e9a578 Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Fri, 13 Nov 2020 14:15:34 +0800 Subject: [PATCH] - Segment Company Relationship Service Class - Update Standard Segment Constant Logic Class - List Standard Segment Constant Logic Class - List Standard Segment Logic Class --- .../General/Eloquent/Filters/SegmentId.php | 20 +++ .../ControllerLogic/CreateUserLogic.php | 32 +++- .../SegmentCompanyObject.php | 44 +++++ .../Services/CreatesSegmentCompany.php | 21 +++ .../Rules/CanCreateSegmentCompany.php | 53 ++++++ .../Validators/SegmentCompanyValidation.php | 40 +++++ .../ListStandardSegmentConstantLogic.php | 69 +++++++ .../UpdateStandardSegmentConstantLogic.php | 170 ++++++++++++++++++ .../SegmentConstantBillingFeeObject.php | 72 ++++++++ .../SegmentConstantBookingAmountMaxObject.php | 86 +++++++++ ...ConstantPaymentAttemptExpiryTimeObject.php | 72 ++++++++ .../SegmentConstantServiceChargeObject.php | 72 ++++++++ .../SegmentConstantTaxObject.php | 72 ++++++++ .../Services/FetchesSegmentConstant.php | 33 ++++ .../Services/ListsSegmentConstants.php | 33 ++++ .../UpdatesSegmentConstantBillingFee.php | 28 +++ ...UpdatesSegmentConstantBookingAmountMax.php | 29 +++ ...egmentConstantPaymentAttemptExpiryTime.php | 28 +++ .../UpdatesSegmentConstantServiceCharge.php | 28 +++ .../Services/UpdatesSegmentConstantTax.php | 28 +++ .../Rules/CanListStandardSegmentConstants.php | 45 +++++ .../CanUpdateStandardSegmentConstant.php | 58 ++++++ .../Validators/SegmentConstantValidation.php | 116 ++++++++++++ .../ListStandardSegmentLogic.php | 65 +++++++ .../Segments/Services/ListsSegments.php | 33 ++++ .../Rules/CanListStandardSegments.php | 45 +++++ ...ListStandardSegmentConstantsController.php | 20 +++ ...pdateStandardSegmentConstantController.php | 20 +++ .../ListStandardSegmentsController.php | 20 +++ .../Resources/SegmentConstantResource.php | 23 +++ app/Http/Resources/SegmentResource.php | 22 +++ app/Models/Company.php | 9 + app/Models/Permission.php | 9 + app/Models/Role.php | 11 ++ app/Models/Segment.php | 22 +++ app/Models/SegmentCompany.php | 18 ++ app/Models/SegmentConstant.php | 28 +++ app/Models/User.php | 14 +- ...020_11_11_065757_create_segments_table.php | 33 ++++ ..._065838_create_segment_constants_table.php | 38 ++++ ..._065851_create_segment_companies_table.php | 34 ++++ .../seeds/AdminUserPermissionsTableSeeder.php | 70 ++++++++ database/seeds/AdminUserTableSeeder.php | 42 +++++ database/seeds/DatabaseSeeder.php | 7 + .../seeds/SegmentConstantsTableSeeder.php | 79 ++++++++ database/seeds/SegmentsTableSeeder.php | 24 +++ .../accounts/forms/LoginFormComponent.vue | 11 +- routes/api.php | 3 + routes/segment.php | 13 ++ routes/segment_constant.php | 13 ++ 50 files changed, 1956 insertions(+), 19 deletions(-) create mode 100644 app/Classes/General/Eloquent/Filters/SegmentId.php create mode 100644 app/Classes/Modules/SegmentCompanies/DataTransferObjects/SegmentCompanyObject.php create mode 100644 app/Classes/Modules/SegmentCompanies/Services/CreatesSegmentCompany.php create mode 100644 app/Classes/Modules/SegmentCompanies/Standards/Rules/CanCreateSegmentCompany.php create mode 100644 app/Classes/Modules/SegmentCompanies/Standards/Validators/SegmentCompanyValidation.php create mode 100644 app/Classes/Modules/SegmentConstants/ControllerLogic/ListStandardSegmentConstantLogic.php create mode 100644 app/Classes/Modules/SegmentConstants/ControllerLogic/UpdateStandardSegmentConstantLogic.php create mode 100644 app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBillingFeeObject.php create mode 100644 app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBookingAmountMaxObject.php create mode 100644 app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantPaymentAttemptExpiryTimeObject.php create mode 100644 app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantServiceChargeObject.php create mode 100644 app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantTaxObject.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/FetchesSegmentConstant.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/ListsSegmentConstants.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBillingFee.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBookingAmountMax.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantPaymentAttemptExpiryTime.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantServiceCharge.php create mode 100644 app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantTax.php create mode 100644 app/Classes/Modules/SegmentConstants/Standards/Rules/CanListStandardSegmentConstants.php create mode 100644 app/Classes/Modules/SegmentConstants/Standards/Rules/CanUpdateStandardSegmentConstant.php create mode 100644 app/Classes/Modules/SegmentConstants/Standards/Validators/SegmentConstantValidation.php create mode 100644 app/Classes/Modules/Segments/ControllerLogic/ListStandardSegmentLogic.php create mode 100644 app/Classes/Modules/Segments/Services/ListsSegments.php create mode 100644 app/Classes/Modules/Segments/Standards/Rules/CanListStandardSegments.php create mode 100644 app/Http/Controllers/StandardSegmentConstants/ListStandardSegmentConstantsController.php create mode 100644 app/Http/Controllers/StandardSegmentConstants/UpdateStandardSegmentConstantController.php create mode 100644 app/Http/Controllers/StandardSegments/ListStandardSegmentsController.php create mode 100644 app/Http/Resources/SegmentConstantResource.php create mode 100644 app/Http/Resources/SegmentResource.php create mode 100644 app/Models/Permission.php create mode 100644 app/Models/Role.php create mode 100644 app/Models/Segment.php create mode 100644 app/Models/SegmentCompany.php create mode 100644 app/Models/SegmentConstant.php create mode 100644 database/migrations/2020_11_11_065757_create_segments_table.php create mode 100644 database/migrations/2020_11_11_065838_create_segment_constants_table.php create mode 100644 database/migrations/2020_11_11_065851_create_segment_companies_table.php create mode 100644 database/seeds/AdminUserPermissionsTableSeeder.php create mode 100644 database/seeds/AdminUserTableSeeder.php create mode 100644 database/seeds/SegmentConstantsTableSeeder.php create mode 100644 database/seeds/SegmentsTableSeeder.php create mode 100644 routes/segment.php create mode 100644 routes/segment_constant.php diff --git a/app/Classes/General/Eloquent/Filters/SegmentId.php b/app/Classes/General/Eloquent/Filters/SegmentId.php new file mode 100644 index 00000000..dade3d25 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/SegmentId.php @@ -0,0 +1,20 @@ +where('segment_id', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php b/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php index 4d3a5ce9..bc898205 100644 --- a/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php @@ -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()); } diff --git a/app/Classes/Modules/SegmentCompanies/DataTransferObjects/SegmentCompanyObject.php b/app/Classes/Modules/SegmentCompanies/DataTransferObjects/SegmentCompanyObject.php new file mode 100644 index 00000000..023d4f57 --- /dev/null +++ b/app/Classes/Modules/SegmentCompanies/DataTransferObjects/SegmentCompanyObject.php @@ -0,0 +1,44 @@ +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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentCompanies/Services/CreatesSegmentCompany.php b/app/Classes/Modules/SegmentCompanies/Services/CreatesSegmentCompany.php new file mode 100644 index 00000000..ae791fca --- /dev/null +++ b/app/Classes/Modules/SegmentCompanies/Services/CreatesSegmentCompany.php @@ -0,0 +1,21 @@ +segment()->sync($object->getSegmentId()); + return $model; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentCompanies/Standards/Rules/CanCreateSegmentCompany.php b/app/Classes/Modules/SegmentCompanies/Standards/Rules/CanCreateSegmentCompany.php new file mode 100644 index 00000000..2670467e --- /dev/null +++ b/app/Classes/Modules/SegmentCompanies/Standards/Rules/CanCreateSegmentCompany.php @@ -0,0 +1,53 @@ +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; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentCompanies/Standards/Validators/SegmentCompanyValidation.php b/app/Classes/Modules/SegmentCompanies/Standards/Validators/SegmentCompanyValidation.php new file mode 100644 index 00000000..2185c519 --- /dev/null +++ b/app/Classes/Modules/SegmentCompanies/Standards/Validators/SegmentCompanyValidation.php @@ -0,0 +1,40 @@ + $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 []; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllerLogic/ListStandardSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllerLogic/ListStandardSegmentConstantLogic.php new file mode 100644 index 00000000..3ce065c1 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllerLogic/ListStandardSegmentConstantLogic.php @@ -0,0 +1,69 @@ + '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()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/ControllerLogic/UpdateStandardSegmentConstantLogic.php b/app/Classes/Modules/SegmentConstants/ControllerLogic/UpdateStandardSegmentConstantLogic.php new file mode 100644 index 00000000..22874fa7 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/ControllerLogic/UpdateStandardSegmentConstantLogic.php @@ -0,0 +1,170 @@ + '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->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->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->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->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->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()); + } + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBillingFeeObject.php b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBillingFeeObject.php new file mode 100644 index 00000000..27b6b676 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBillingFeeObject.php @@ -0,0 +1,72 @@ +name = $name; + $this->reference = $reference; + $this->type = $type; + $this->value = $value; + } + + /** + * @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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBookingAmountMaxObject.php b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBookingAmountMaxObject.php new file mode 100644 index 00000000..3575af1f --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantBookingAmountMaxObject.php @@ -0,0 +1,86 @@ +name = $name; + $this->reference = $reference; + $this->type = $type; + $this->value = $value; + $this->currency_id = $currency_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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantPaymentAttemptExpiryTimeObject.php b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantPaymentAttemptExpiryTimeObject.php new file mode 100644 index 00000000..758835d5 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantPaymentAttemptExpiryTimeObject.php @@ -0,0 +1,72 @@ +name = $name; + $this->reference = $reference; + $this->type = $type; + $this->value = $value; + } + + /** + * @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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantServiceChargeObject.php b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantServiceChargeObject.php new file mode 100644 index 00000000..67d6e284 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantServiceChargeObject.php @@ -0,0 +1,72 @@ +name = $name; + $this->reference = $reference; + $this->type = $type; + $this->value = $value; + } + + /** + * @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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantTaxObject.php b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantTaxObject.php new file mode 100644 index 00000000..d07eb19b --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/DataTransferObjects/SegmentConstantTaxObject.php @@ -0,0 +1,72 @@ +name = $name; + $this->reference = $reference; + $this->type = $type; + $this->value = $value; + } + + /** + * @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; + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/FetchesSegmentConstant.php b/app/Classes/Modules/SegmentConstants/Services/FetchesSegmentConstant.php new file mode 100644 index 00000000..003e20ba --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/FetchesSegmentConstant.php @@ -0,0 +1,33 @@ +repository = $repository; + } + + + /** + * @return Builder + */ + public function getRepository(): Builder + { + return $this->repository->newQuery(); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/ListsSegmentConstants.php b/app/Classes/Modules/SegmentConstants/Services/ListsSegmentConstants.php new file mode 100644 index 00000000..5f959f98 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/ListsSegmentConstants.php @@ -0,0 +1,33 @@ +repository = $repository; + } + + + /** + * @return Builder + */ + function getRepository(): Builder + { + return $this->repository->newQuery(); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBillingFee.php b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBillingFee.php new file mode 100644 index 00000000..573d287b --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBillingFee.php @@ -0,0 +1,28 @@ +name = $object->getName(); + $model->reference = $object->getReference(); + $model->detail = json_encode([ + 'type' => $object->getType(), + 'value' => $object->getValue() + ]); + + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBookingAmountMax.php b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBookingAmountMax.php new file mode 100644 index 00000000..8885a701 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantBookingAmountMax.php @@ -0,0 +1,29 @@ +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); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantPaymentAttemptExpiryTime.php b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantPaymentAttemptExpiryTime.php new file mode 100644 index 00000000..5acdd9e9 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantPaymentAttemptExpiryTime.php @@ -0,0 +1,28 @@ +name = $object->getName(); + $model->reference = $object->getReference(); + $model->detail = json_encode([ + 'type' => $object->getType(), + 'value' => $object->getValue() + ]); + + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantServiceCharge.php b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantServiceCharge.php new file mode 100644 index 00000000..afa201f5 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantServiceCharge.php @@ -0,0 +1,28 @@ +name = $object->getName(); + $model->reference = $object->getReference(); + $model->detail = json_encode([ + 'type' => $object->getType(), + 'value' => $object->getValue() + ]); + + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantTax.php b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantTax.php new file mode 100644 index 00000000..2b02e9f9 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Services/UpdatesSegmentConstantTax.php @@ -0,0 +1,28 @@ +name = $object->getName(); + $model->reference = $object->getReference(); + $model->detail = json_encode([ + 'type' => $object->getType(), + 'value' => $object->getValue() + ]); + + return $this->handler($model); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Standards/Rules/CanListStandardSegmentConstants.php b/app/Classes/Modules/SegmentConstants/Standards/Rules/CanListStandardSegmentConstants.php new file mode 100644 index 00000000..094cdd48 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Standards/Rules/CanListStandardSegmentConstants.php @@ -0,0 +1,45 @@ +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; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Standards/Rules/CanUpdateStandardSegmentConstant.php b/app/Classes/Modules/SegmentConstants/Standards/Rules/CanUpdateStandardSegmentConstant.php new file mode 100644 index 00000000..fb4f39a3 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Standards/Rules/CanUpdateStandardSegmentConstant.php @@ -0,0 +1,58 @@ +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); + } + + /** + * @param SegmentConstantValidation $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/SegmentConstants/Standards/Validators/SegmentConstantValidation.php b/app/Classes/Modules/SegmentConstants/Standards/Validators/SegmentConstantValidation.php new file mode 100644 index 00000000..d382d343 --- /dev/null +++ b/app/Classes/Modules/SegmentConstants/Standards/Validators/SegmentConstantValidation.php @@ -0,0 +1,116 @@ +reference = $object->getReference(); + if ($this->reference == 'TAX') { + return [ + 'name' => $object->getName(), + 'reference' => $object->getReference(), + 'type' => $object->getType(), + 'value' => $object->getValue() + ]; + } + elseif ($this->reference == 'BILLING_FEE') { + return [ + 'name' => $object->getName(), + 'reference' => $object->getReference(), + 'type' => $object->getType(), + 'value' => $object->getValue() + ]; + } + elseif ($this->reference == 'SERVICE_CHARGE') { + return [ + 'name' => $object->getName(), + 'reference' => $object->getReference(), + 'type' => $object->getType(), + 'value' => $object->getValue() + ]; + } + elseif ($this->reference == 'BOOKING_AMOUNT_MAX') { + return [ + 'name' => $object->getName(), + 'reference' => $object->getReference(), + 'type' => $object->getType(), + 'value' => $object->getValue(), + 'currency_id' => $object->getCurrencyId() + ]; + } + elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') { + return [ + 'name' => $object->getName(), + 'reference' => $object->getReference(), + 'type' => $object->getType(), + 'value' => $object->getValue() + ]; + } + } + + /** + * @return array + */ + protected function rules(): array { + + if ($this->reference == 'TAX') { + return [ + 'name' => 'required', + 'reference' => 'required', + 'type' => 'required', + 'value' => 'required' + ]; + } + elseif ($this->reference == 'BILLING_FEE') { + return [ + 'name' => 'required', + 'reference' => 'required', + 'type' => 'required', + 'value' => 'required' + ]; + } + elseif ($this->reference == 'SERVICE_CHARGE') { + return [ + 'name' => 'required', + 'reference' => 'required', + 'type' => 'required', + 'value' => 'required' + ]; + } + elseif ($this->reference == 'BOOKING_AMOUNT_MAX') { + return [ + 'name' => 'required', + 'reference' => 'required', + 'type' => 'required', + 'value' => 'required', + 'currency_id' => 'required' + ]; + } + elseif ($this->reference == 'PAYMENT_ATTEMP_EXPIRY_TIME') { + return [ + 'name' => 'required', + 'reference' => 'required', + 'type' => 'required', + 'value' => 'required', + ]; + } + } + + /** + * @return array + */ + protected function messages(): array { + return []; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Segments/ControllerLogic/ListStandardSegmentLogic.php b/app/Classes/Modules/Segments/ControllerLogic/ListStandardSegmentLogic.php new file mode 100644 index 00000000..6458962b --- /dev/null +++ b/app/Classes/Modules/Segments/ControllerLogic/ListStandardSegmentLogic.php @@ -0,0 +1,65 @@ + '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()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Segments/Services/ListsSegments.php b/app/Classes/Modules/Segments/Services/ListsSegments.php new file mode 100644 index 00000000..af44820d --- /dev/null +++ b/app/Classes/Modules/Segments/Services/ListsSegments.php @@ -0,0 +1,33 @@ +repository = $repository; + } + + + /** + * @return Builder + */ + function getRepository(): Builder + { + return $this->repository->newQuery(); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Segments/Standards/Rules/CanListStandardSegments.php b/app/Classes/Modules/Segments/Standards/Rules/CanListStandardSegments.php new file mode 100644 index 00000000..7f71182e --- /dev/null +++ b/app/Classes/Modules/Segments/Standards/Rules/CanListStandardSegments.php @@ -0,0 +1,45 @@ +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; + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/StandardSegmentConstants/ListStandardSegmentConstantsController.php b/app/Http/Controllers/StandardSegmentConstants/ListStandardSegmentConstantsController.php new file mode 100644 index 00000000..b921540e --- /dev/null +++ b/app/Http/Controllers/StandardSegmentConstants/ListStandardSegmentConstantsController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/StandardSegmentConstants/UpdateStandardSegmentConstantController.php b/app/Http/Controllers/StandardSegmentConstants/UpdateStandardSegmentConstantController.php new file mode 100644 index 00000000..8c883031 --- /dev/null +++ b/app/Http/Controllers/StandardSegmentConstants/UpdateStandardSegmentConstantController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/StandardSegments/ListStandardSegmentsController.php b/app/Http/Controllers/StandardSegments/ListStandardSegmentsController.php new file mode 100644 index 00000000..0218ac37 --- /dev/null +++ b/app/Http/Controllers/StandardSegments/ListStandardSegmentsController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Resources/SegmentConstantResource.php b/app/Http/Resources/SegmentConstantResource.php new file mode 100644 index 00000000..aa939d8e --- /dev/null +++ b/app/Http/Resources/SegmentConstantResource.php @@ -0,0 +1,23 @@ + $this->id, + 'name' => $this->name, + 'detail' => $this->detail + ]; + } +} diff --git a/app/Http/Resources/SegmentResource.php b/app/Http/Resources/SegmentResource.php new file mode 100644 index 00000000..f07e9661 --- /dev/null +++ b/app/Http/Resources/SegmentResource.php @@ -0,0 +1,22 @@ + $this->id, + 'name' => $this->name, + ]; + } +} diff --git a/app/Models/Company.php b/app/Models/Company.php index 7d2f785e..f791ddeb 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -1,6 +1,7 @@ belongsToMany(Segment::class, 'segment_company', 'company_id', 'segment_id'); + } } diff --git a/app/Models/Permission.php b/app/Models/Permission.php new file mode 100644 index 00000000..9245cdd8 --- /dev/null +++ b/app/Models/Permission.php @@ -0,0 +1,9 @@ +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 */ diff --git a/database/migrations/2020_11_11_065757_create_segments_table.php b/database/migrations/2020_11_11_065757_create_segments_table.php new file mode 100644 index 00000000..4bfa3f05 --- /dev/null +++ b/database/migrations/2020_11_11_065757_create_segments_table.php @@ -0,0 +1,33 @@ +id(); + $table->string('name')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('segments'); + } +} diff --git a/database/migrations/2020_11_11_065838_create_segment_constants_table.php b/database/migrations/2020_11_11_065838_create_segment_constants_table.php new file mode 100644 index 00000000..a64fef62 --- /dev/null +++ b/database/migrations/2020_11_11_065838_create_segment_constants_table.php @@ -0,0 +1,38 @@ +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'); + } +} diff --git a/database/migrations/2020_11_11_065851_create_segment_companies_table.php b/database/migrations/2020_11_11_065851_create_segment_companies_table.php new file mode 100644 index 00000000..f2a55572 --- /dev/null +++ b/database/migrations/2020_11_11_065851_create_segment_companies_table.php @@ -0,0 +1,34 @@ +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'); + } +} diff --git a/database/seeds/AdminUserPermissionsTableSeeder.php b/database/seeds/AdminUserPermissionsTableSeeder.php new file mode 100644 index 00000000..ad723699 --- /dev/null +++ b/database/seeds/AdminUserPermissionsTableSeeder.php @@ -0,0 +1,70 @@ +forget('spatie.permission.cache'); + + // admin permissions + 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 non_segment', 'guard_name' => 'web']); + Permission::create(['name' => 'add non_segment', 'guard_name' => 'web']); + Permission::create(['name' => 'edit non_segment', 'guard_name' => 'web']); + Permission::create(['name' => 'delete non_segment', 'guard_name' => 'web']); + + Permission::create(['name' => 'view non_segment_constant', 'guard_name' => 'web']); + Permission::create(['name' => 'add non_segment_constant', 'guard_name' => 'web']); + Permission::create(['name' => 'edit non_segment_constant', 'guard_name' => 'web']); + Permission::create(['name' => 'delete non_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); + + /////////////////////////////////////////////////////////////////////// + } +} diff --git a/database/seeds/AdminUserTableSeeder.php b/database/seeds/AdminUserTableSeeder.php new file mode 100644 index 00000000..0eb00cba --- /dev/null +++ b/database/seeds/AdminUserTableSeeder.php @@ -0,0 +1,42 @@ +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'), + ] + ]); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b02b426f..cdfc22d4 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -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(); } } diff --git a/database/seeds/SegmentConstantsTableSeeder.php b/database/seeds/SegmentConstantsTableSeeder.php new file mode 100644 index 00000000..283bb4d5 --- /dev/null +++ b/database/seeds/SegmentConstantsTableSeeder.php @@ -0,0 +1,79 @@ +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'), + ], + ]); + } +} diff --git a/database/seeds/SegmentsTableSeeder.php b/database/seeds/SegmentsTableSeeder.php new file mode 100644 index 00000000..bda12c31 --- /dev/null +++ b/database/seeds/SegmentsTableSeeder.php @@ -0,0 +1,24 @@ +insert([ + [ + 'id' => 1, + 'name' => 'Standard Segment', + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + ] + ]); + } +} diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue index 98aa3746..1528f831 100644 --- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -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: ''}); diff --git a/routes/api.php b/routes/api.php index 343abddc..6ff3b10c 100644 --- a/routes/api.php +++ b/routes/api.php @@ -17,6 +17,9 @@ use Illuminate\Support\Facades\Route; Route::group(['middleware' => 'api', 'prefix' => 'v1', 'as' => 'api.'], function () { require __DIR__ . '/account.php'; + require __DIR__ . '/segment.php'; + require __DIR__ . '/segment_constant.php'; + Route::group(['middleware' => 'valid.token'], function () { require __DIR__ . '/crud.php'; diff --git a/routes/segment.php b/routes/segment.php new file mode 100644 index 00000000..6038c6e8 --- /dev/null +++ b/routes/segment.php @@ -0,0 +1,13 @@ + 'StandardSegments'], function () { + + Route::group(['middleware' => 'valid.token'], function () { + Route::group(['prefix' => 'standard-segment'], function () { + Route::get('/list', 'ListStandardSegmentsController@list')->name('standard_segment.update'); + Route::put('/update/{id}', 'StandardSegmentController@update')->name('standard_segment.update'); + }); + }); +}); \ No newline at end of file diff --git a/routes/segment_constant.php b/routes/segment_constant.php new file mode 100644 index 00000000..fe2ff141 --- /dev/null +++ b/routes/segment_constant.php @@ -0,0 +1,13 @@ + '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'); + }); + }); +}); \ No newline at end of file