diff --git a/app/Classes/General/Interfaces/Notifiable.php b/app/Classes/General/Interfaces/Notifiable.php
new file mode 100644
index 00000000..e9d8f22d
--- /dev/null
+++ b/app/Classes/General/Interfaces/Notifiable.php
@@ -0,0 +1,15 @@
+canApproveDocument = $canApproveDocument;
$this->approvesDocument = $approvesDocument;
$this->rejectsDocument = $rejectsDocument;
$this->fetchesDocument = $fetchesDocument;
$this->updatesCompanyStatus = $updatesCompanyStatus;
+ $this->createNotificationProcessor = $createNotificationProcessor;
}
/**
@@ -84,6 +92,20 @@ 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->employees()->first(),
+ $document,
+ );
+
+ $this->createNotificationProcessor->execute($object);
+
+ if($status === 'approve'){
+ $orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
+ }
+
return $this->resourceResponse(new DocumentResource($document));
}
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/DataTransferObjects/NotificationObject.php b/app/Classes/Modules/Notifications/DataTransferObjects/NotificationObject.php
new file mode 100644
index 00000000..40dc4f3c
--- /dev/null
+++ b/app/Classes/Modules/Notifications/DataTransferObjects/NotificationObject.php
@@ -0,0 +1,101 @@
+title = $title;
+ $this->description = $description;
+ $this->subject = $subject;
+ $this->target = $target;
+ $this->causer = $causer;
+ $this->status = $status;
+ }
+
+ /**
+ * @return int
+ */
+ public function getTitle(): string
+ {
+ return $this->title;
+ }
+
+ /**
+ * @return int
+ */
+ public function getDescription(): string
+ {
+ return $this->description;
+ }
+
+ /**
+ * @return Notifiable
+ */
+ public function getSubject(): Notifiable
+ {
+ return $this->subject;
+ }
+
+ /**
+ * @return Notifiable
+ */
+ public function getTarget(): Notifiable
+ {
+ return $this->target;
+ }
+
+ /**
+ * @return Notifiable
+ */
+ public function getCauser(): Notifiable
+ {
+ return $this->causer;
+ }
+
+ /**
+ * @return int
+ */
+ public function getStatus(): int
+ {
+ return $this->status;
+ }
+
+
+}
diff --git a/app/Classes/Modules/Notifications/Processors/CreateNotificationProcessor.php b/app/Classes/Modules/Notifications/Processors/CreateNotificationProcessor.php
new file mode 100644
index 00000000..d6b077f8
--- /dev/null
+++ b/app/Classes/Modules/Notifications/Processors/CreateNotificationProcessor.php
@@ -0,0 +1,27 @@
+createsNotification = $createsNotification;
+ }
+
+ public function execute(NotificationObject $object)
+ {
+ $notification = $this->createsNotification->execute($object);
+ return $notification;
+ }
+}
diff --git a/app/Classes/Modules/Notifications/Services/CreatesNotification.php b/app/Classes/Modules/Notifications/Services/CreatesNotification.php
new file mode 100644
index 00000000..4f5ca5fd
--- /dev/null
+++ b/app/Classes/Modules/Notifications/Services/CreatesNotification.php
@@ -0,0 +1,30 @@
+title = $object->getTitle();
+ $model->description = $object->getDescription();
+ $model->status = $object->getStatus();
+ $model->subject_type = get_class($object->getSubject());
+ $model->subject_id = $object->getSubject()->id;
+ $model->target_type = get_class($object->getTarget());
+ $model->target_id = $object->getTarget()->id;
+ $model->causer_type = get_class($object->getCauser());
+ $model->causer_id = $object->getCauser()->id;
+ $model->save();
+
+ return $model;
+ }
+}
\ 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/app/Models/AbstractModel.php b/app/Models/AbstractModel.php
index 7a7c9c06..47d8754b 100644
--- a/app/Models/AbstractModel.php
+++ b/app/Models/AbstractModel.php
@@ -3,11 +3,37 @@
namespace App\Models;
+use App\Classes\General\Interfaces\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
+use Illuminate\Database\Eloquent\Relations\MorphTo;
-class AbstractModel extends Model
+class AbstractModel extends Model implements Notifiable
{
use LogsActivity;
protected static $logFillable = true;
+
+ /**
+ * @return MorphTo
+ */
+ public function subject(): MorphTo
+ {
+ return $this->MorphTo('subject');
+ }
+
+ /**
+ * @return MorphTo
+ */
+ public function target(): MorphTo
+ {
+ return $this->MorphTo('target');
+ }
+
+ /**
+ * @return MorphTo
+ */
+ public function causer(): MorphTo
+ {
+ return $this->MorphTo('causer');
+ }
}
\ No newline at end of file
diff --git a/app/Models/Notification.php b/app/Models/Notification.php
new file mode 100644
index 00000000..06bd6024
--- /dev/null
+++ b/app/Models/Notification.php
@@ -0,0 +1,18 @@
+BelongsTo(Package::class, 'package_id', 'id');
+ }
+}
diff --git a/database/migrations/2022_04_15_211421_create_notifications_table.php b/database/migrations/2022_04_15_211421_create_notifications_table.php
new file mode 100644
index 00000000..d14cdc89
--- /dev/null
+++ b/database/migrations/2022_04_15_211421_create_notifications_table.php
@@ -0,0 +1,40 @@
+id();
+ $table->string('title');
+ $table->text('description');
+ $table->morphs('subject');
+ $table->morphs('target');
+ $table->morphs('causer');
+ $table->integer('status')->default(ApprovalStatus::APPROVED);
+ $table->softDeletes();
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('notifications');
+ }
+}
diff --git a/resources/assets/sass/modules/_typography.scss b/resources/assets/sass/modules/_typography.scss
index 605b8e7c..aa4506a9 100644
--- a/resources/assets/sass/modules/_typography.scss
+++ b/resources/assets/sass/modules/_typography.scss
@@ -316,6 +316,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 64fc74e2..838764a3 100644
--- a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue
+++ b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue
@@ -123,28 +123,7 @@
Reject Document
-