diff --git a/app/Classes/General/Eloquent/Filters/TargetId.php b/app/Classes/General/Eloquent/Filters/TargetId.php new file mode 100644 index 00000000..2bd7045e --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/TargetId.php @@ -0,0 +1,21 @@ +where('target_type', User::class)->where('target_id', $value); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/ApproveIdentificationDocumentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/ApproveIdentificationDocumentLogic.php index 0d3f007a..af42a35a 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/ApproveIdentificationDocumentLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/ApproveIdentificationDocumentLogic.php @@ -14,6 +14,8 @@ use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Documents\Services\FetchesDocument; use App\Classes\Modules\Documents\Services\ApprovesDocument; +use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject; +Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor; use App\Models\Document; use Illuminate\Http\JsonResponse; @@ -50,6 +52,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic /** @var UpdatesOrdersStatus */ private $updatesOrdersStatus; + /** @var CreateNotificationProcessor */ + private $createNotificationProcessor; + /** * ApproveIdentificationDocumentLogic constructor. * @param CanApproveDocument $canApproveDocument @@ -58,8 +63,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic * @param FetchesDocument $fetchesDocument * @param UpdatesCompanyStatus $updatesCompanyStatus * @param UpdatesOrdersStatus $updatesOrdersStatus + * @param CreateNotificationProcessor $createNotificationProcessor */ - public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus) + public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor) { $this->canApproveDocument = $canApproveDocument; $this->approvesDocument = $approvesDocument; @@ -67,6 +73,7 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic $this->fetchesDocument = $fetchesDocument; $this->updatesCompanyStatus = $updatesCompanyStatus; $this->updatesOrdersStatus = $updatesOrdersStatus; + $this->createNotificationProcessor = $createNotificationProcessor; } /** @@ -90,6 +97,16 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic $this->updatesCompanyStatus->execute($document->owner, $status === 'approve' ? ApprovalStatus::APPROVED : ApprovalStatus::REJECTED); + $object = new NotificationObject( + 'ID Verification ' . ( $status === 'approve' ? 'Approved' : 'Rejected' ), + ( $status === 'approve' ? 'Dear user, congratulations that your ' : 'Dear user, we are sorry to inform you that your ' ) . ( $document->type === 'IDENTITY_CARD' ? 'IC' : 'SSM' ) . ( $status === 'approve' ? ' has been approved. Start your first order now!' : ' has been rejected due to ' . ( $request->input('rejectRemark') ?? '' ) . ', please resubmit it for further action.' ), + $document->owner, + $document->owner->companyModules()->first()->employees()->first(), + $document, + ); + + $this->createNotificationProcessor->execute($object); + if($status === 'approve'){ $orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED); } diff --git a/app/Classes/Modules/Notifications/ControllersLogic/ListNotificationsLogic.php b/app/Classes/Modules/Notifications/ControllersLogic/ListNotificationsLogic.php new file mode 100644 index 00000000..0fdbf6f9 --- /dev/null +++ b/app/Classes/Modules/Notifications/ControllersLogic/ListNotificationsLogic.php @@ -0,0 +1,61 @@ + 'Retrieve Notifications', + 'message' => 'You have successfully retrieved a list of Notifications' + ]; + } + + /** @var ListsNotification */ + private $listsNotification; + + /** + * ListNotificationsLogic constructor. + * @param ListsNotification $listsNotification + */ + public function __construct( + ListsNotification $listsNotification + ) + { + $this->listsNotification = $listsNotification; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + + $filters = [ + // 'target_id'=>auth()->user()->id, + // 'per_page'=>$request->route('per_page') + ]; + + $notifications = $this->listsNotification->execute($filters); + + return $this->collectionResponse(NotificationResource::collection($notifications)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Notifications/Services/ListsNotification.php b/app/Classes/Modules/Notifications/Services/ListsNotification.php new file mode 100644 index 00000000..707e7ae8 --- /dev/null +++ b/app/Classes/Modules/Notifications/Services/ListsNotification.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/Http/Controllers/Notifications/ListNotificationsController.php b/app/Http/Controllers/Notifications/ListNotificationsController.php new file mode 100644 index 00000000..58455fc2 --- /dev/null +++ b/app/Http/Controllers/Notifications/ListNotificationsController.php @@ -0,0 +1,19 @@ +execute($request); + } +} \ No newline at end of file diff --git a/app/Http/Resources/NotificationResource.php b/app/Http/Resources/NotificationResource.php new file mode 100644 index 00000000..564b7b31 --- /dev/null +++ b/app/Http/Resources/NotificationResource.php @@ -0,0 +1,30 @@ + $this->id, + 'title' => $this->title, + 'description' => $this->description, + 'long_ago' => $this->created_at->diffForHumans(), + 'created_at' => $this->created_at->format('d-m-Y') + ]; + + } +} diff --git a/resources/assets/sass/modules/_typography.scss b/resources/assets/sass/modules/_typography.scss index a22dc2fc..60817d2a 100644 --- a/resources/assets/sass/modules/_typography.scss +++ b/resources/assets/sass/modules/_typography.scss @@ -317,6 +317,12 @@ hr{ background-color: $color-primary-lighter !important; } +.bg-primary-lighter-hover { + &:hover { + background-color: $color-primary-lighter !important; + } +} + /* Complete ------------------------------------ */ diff --git a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue index 29edf834..7a9fe7a8 100644 --- a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue +++ b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue @@ -137,28 +137,7 @@ -
-
-
-
-
-
-
Reject Document
-
Are you sure you want to reject this customer's identification?
-
-
-
-
-
Cancel
-
-
-
Reject
-
-
-
-
-
-
+
diff --git a/resources/assets/vue/components/general/elements/NotificationSectionComponent.vue b/resources/assets/vue/components/general/elements/NotificationSectionComponent.vue new file mode 100644 index 00000000..e0f6fb1c --- /dev/null +++ b/resources/assets/vue/components/general/elements/NotificationSectionComponent.vue @@ -0,0 +1,98 @@ + + \ No newline at end of file diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index f1691bcb..5a37f886 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -10,6 +10,9 @@ +
+ +
diff --git a/routes/web.php b/routes/web.php index c700e3c3..bf8c6ca7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -368,6 +368,4 @@ Route::get('/customers/active/{active_start}/{active_end}/{inactive_start?}/{ina Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); -Route::get('/order/{id}', function ($id) { - return view('pages.orders.profile', ['id' => $id]); -})->name('order.details'); \ No newline at end of file +Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list');