diff --git a/.gitignore b/.gitignore
index eec23d5b..cb3842ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
+/storage/file
diff --git a/app/Classes/General/Abstracts/AbstractValidation.php b/app/Classes/General/Abstracts/AbstractValidation.php
index ce168573..27f51272 100644
--- a/app/Classes/General/Abstracts/AbstractValidation.php
+++ b/app/Classes/General/Abstracts/AbstractValidation.php
@@ -34,9 +34,9 @@ abstract class AbstractValidation
* @return bool
* @throws RequestValidationException
*/
- public function validate(DataTransferObject $object){
-
- $validator = $this->validator::make($this->data($object), $this->rules(), $this->messages());
+ public function validate(DataTransferObject $object, ?string $type = 'POST')
+ {
+ $validator = $this->validator::make($this->data($object), $this->rules($type), $this->messages());
if($validator->fails()) {
throw new RequestValidationException($validator->messages()->first());
diff --git a/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php b/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php
index 74e1a74c..4d3a5ce9 100644
--- a/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php
+++ b/app/Classes/Modules/Accounts/ControllerLogic/CreateUserLogic.php
@@ -122,7 +122,7 @@ class CreateUserLogic extends AbstractControllerLogic
$company_object = new CompanyObject(
$request->input('company_name'),
$request->input('company_reference'),
- 1
+ null
);
$this->canCreateCompany->passes($company_object);
diff --git a/app/Classes/Modules/Accounts/ControllerLogic/RegistrationStep2Logic.php b/app/Classes/Modules/Accounts/ControllerLogic/RegistrationStep2Logic.php
new file mode 100644
index 00000000..06f1286b
--- /dev/null
+++ b/app/Classes/Modules/Accounts/ControllerLogic/RegistrationStep2Logic.php
@@ -0,0 +1,157 @@
+ 'Registration Step 2',
+ 'message' => 'You have completed registration step 2'
+ ];
+ }
+
+ /** @var FetchesUser */
+ private $fetchesUser;
+
+ /** @var CanUpdateCompany */
+ private $canUpdateCompany;
+
+ /** @var UpdatesCompany */
+ private $updatesCompany;
+
+ /** @var CanCreateDocument */
+ private $canCreateDocument;
+
+ /** @var CreatesDocument */
+ private $createsDocument;
+
+ /** @var CanCreateFile */
+ private $canCreateFIle;
+
+ /** @var CreatesFile */
+ private $createsFile;
+
+ /** @var Convert64ToFile */
+ private $convert64ToFile;
+
+ /**
+ * UpdateUserControllerLogic constructor.
+ * @param FetchesUser $fetchesUser
+ * @param CanUpdateCompany $canUpdateCompany
+ * @param UpdatesCompany $updatesCompany
+ * @param CanCreateDocument $canCreateDocument
+ * @param CreatesDocument $createsDocument
+ * @param CanCreateFile $canCreateFile
+ * @param CreatesFile $createsFile
+ */
+ public function __construct(
+ FetchesUser $fetchesUser,
+ CanUpdateCompany $canUpdateCompany,
+ UpdatesCompany $updatesCompany,
+ CanCreateDocument $canCreateDocument,
+ CreatesDocument $createsDocument,
+ CanCreateFile $canCreateFile,
+ CreatesFile $createsFile,
+ Convert64ToFile $convert64ToFile
+ )
+ {
+ $this->fetchesUser = $fetchesUser;
+ $this->canUpdateCompany = $canUpdateCompany;
+ $this->updatesCompany = $updatesCompany;
+ $this->canCreateDocument = $canCreateDocument;
+ $this->createsDocument = $createsDocument;
+ $this->canCreateFile = $canCreateFile;
+ $this->createsFile = $createsFile;
+ $this->convert64ToFile = $convert64ToFile;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws ErrorException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ try {
+ DB::beginTransaction();
+
+ $user_query = $this->fetchesUser->execute(['id' => \Auth::user()->id]);
+ $company_query = $user_query->company()->first();
+
+ $company_object = new CompanyObject(
+ $request->input('company_name', $company_query->name),
+ $request->input('company_reference', $company_query->refence),
+ $request->input('type', $company_query->type)
+ );
+ $this->canUpdateCompany->passes($company_object);
+ $company_query = $this->updatesCompany->execute($company_query, $company_object);
+
+ $document_type = $company_query->type == 1 ? DocumentType::COMPANY_PUBLIC_SMS_REGISTER : DocumentType::COMPANY_PERSONAL_IC;
+ $document_object = new DocumentObject(
+ $user_query->id,
+ OwnerType::COMPANY,
+ $document_type,
+ $request->input('document_reference'),
+ ObjectStatus::PENDING,
+ null,
+ null,
+ null,
+ null
+ );
+ $this->canCreateDocument->passes($document_object);
+ $document_query = $this->createsDocument->execute($document_object);
+
+ $file = $this->convert64ToFile->convert($request->input('file'));
+ $file_type = $company_query->type == 1 ? FileType::COMPANY_PUBLIC_SMS_REGISTER : FileType::COMPANY_PERSONAL_IC;
+
+ $file_object = new FileObject(
+ $document_query->id,
+ !empty($file[0]) ? json_encode($file[0]) : null,
+ $file_type
+ );
+ $this->canCreateFile->passes($file_object);
+ $file_query = $this->createsFile->execute($file_object);
+
+ DB::commit();
+
+ return $this->resourceResponse(new UserResource(\Auth::user()));
+
+ } catch (\Exception $exception) {
+ throw new ErrorException($exception->getMessage(), $exception->getCode());
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php b/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php
new file mode 100644
index 00000000..e28e7a35
--- /dev/null
+++ b/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php
@@ -0,0 +1,157 @@
+ 'Update User',
+ 'message' => 'You have successfully update a user'
+ ];
+ }
+
+ /** @var FetchesUser */
+ private $fetchesUser;
+
+ /** @var CanUpdateCompany */
+ private $canUpdateCompany;
+
+ /** @var UpdatesCompany */
+ private $updatesCompany;
+
+ /** @var CanCreateDocument */
+ private $canCreateDocument;
+
+ /** @var CreatesDocument */
+ private $createsDocument;
+
+ /** @var CanCreateFile */
+ private $canCreateFIle;
+
+ /** @var CreatesFile */
+ private $createsFile;
+
+ /** @var Convert64ToFile */
+ private $convert64ToFile;
+
+ /**
+ * UpdateUserControllerLogic constructor.
+ * @param FetchesUser $fetchesUser
+ * @param CanUpdateCompany $canUpdateCompany
+ * @param UpdatesCompany $updatesCompany
+ * @param CanCreateDocument $canCreateDocument
+ * @param CreatesDocument $createsDocument
+ * @param CanCreateFile $canCreateFile
+ * @param CreatesFile $createsFile
+ */
+ public function __construct(
+ FetchesUser $fetchesUser,
+ CanUpdateCompany $canUpdateCompany,
+ UpdatesCompany $updatesCompany,
+ CanCreateDocument $canCreateDocument,
+ CreatesDocument $createsDocument,
+ CanCreateFile $canCreateFile,
+ CreatesFile $createsFile,
+ Convert64ToFile $convert64ToFile
+ )
+ {
+ $this->fetchesUser = $fetchesUser;
+ $this->canUpdateCompany = $canUpdateCompany;
+ $this->updatesCompany = $updatesCompany;
+ $this->canCreateDocument = $canCreateDocument;
+ $this->createsDocument = $createsDocument;
+ $this->canCreateFile = $canCreateFile;
+ $this->createsFile = $createsFile;
+ $this->convert64ToFile = $convert64ToFile;
+ }
+
+ /**
+ * @param Request $request
+ * @return JsonResponse
+ * @throws ErrorException
+ */
+ public function logic(Request $request) : JsonResponse
+ {
+ try {
+ DB::beginTransaction();
+
+ $user_query = $this->fetchesUser->execute(['id' => \Auth::user()->id]);
+ $company_query = $user_query->company()->first();
+
+ $company_object = new CompanyObject(
+ $request->input('company_name', $company_query->name),
+ $request->input('company_reference', $company_query->refence),
+ $request->input('type', $company_query->type)
+ );
+ $this->canUpdateCompany->passes($company_object);
+ $company_query = $this->updatesCompany->execute($company_query, $company_object);
+
+ $document_type = $company_query->type == 1 ? DocumentType::COMPANY_PUBLIC_SMS_REGISTER : DocumentType::COMPANY_PERSONAL_IC;
+ $document_object = new DocumentObject(
+ $user_query->id,
+ OwnerType::COMPANY,
+ $document_type,
+ $request->input('document_reference'),
+ ObjectStatus::PENDING,
+ null,
+ null,
+ null,
+ null
+ );
+ $this->canCreateDocument->passes($document_object);
+ $document_query = $this->createsDocument->execute($document_object);
+
+ $file = $this->convert64ToFile->convert($request->input('file'));
+ $file_type = $company_query->type == 1 ? FileType::COMPANY_PUBLIC_SMS_REGISTER : FileType::COMPANY_PERSONAL_IC;
+
+ $file_object = new FileObject(
+ $document_query->id,
+ !empty($file[0]) ? json_encode($file[0]) : null,
+ $file_type
+ );
+ $this->canCreateFile->passes($file_object);
+ $file_query = $this->createsFile->execute($file_object);
+
+ DB::commit();
+
+ return $this->resourceResponse(new UserResource(\Auth::user()));
+
+ } catch (\Exception $exception) {
+ throw new ErrorException($exception->getMessage(), $exception->getCode());
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Accounts/Services/FetchesUser.php b/app/Classes/Modules/Accounts/Services/FetchesUser.php
new file mode 100644
index 00000000..4f482c9f
--- /dev/null
+++ b/app/Classes/Modules/Accounts/Services/FetchesUser.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/Companies/DataTransferObjects/CompanyObject.php b/app/Classes/Modules/Companies/DataTransferObjects/CompanyObject.php
index 02d5f2a5..da9905e9 100644
--- a/app/Classes/Modules/Companies/DataTransferObjects/CompanyObject.php
+++ b/app/Classes/Modules/Companies/DataTransferObjects/CompanyObject.php
@@ -51,7 +51,7 @@ class CompanyObject implements DataTransferObject
/**
* @return int
*/
- public function getType(): int
+ public function getType(): ?int
{
return $this->type;
}
diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompany.php b/app/Classes/Modules/Companies/Services/UpdatesCompany.php
new file mode 100644
index 00000000..876221d1
--- /dev/null
+++ b/app/Classes/Modules/Companies/Services/UpdatesCompany.php
@@ -0,0 +1,25 @@
+name = $object->getName();
+ $model->reference = $object->getReference();
+ $model->type = $object->getType();
+
+ return $this->handler($model);
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompany.php b/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompany.php
new file mode 100644
index 00000000..7f0fd974
--- /dev/null
+++ b/app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompany.php
@@ -0,0 +1,50 @@
+companyValidation = $companyValidation;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function authorized(): bool
+ {
+ // TODO Set Authorization rules
+ return true;
+ }
+
+ /**
+ * @param UserObject $object
+ * @return bool
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ protected function validators($object): bool
+ {
+ return $this->companyValidation->validate($object, 'PUT');
+ }
+
+ /**
+ * @param UserObject $object
+ * @return bool
+ */
+ protected function criteria($object): bool
+ {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php b/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php
index 0ecab47d..027d3287 100644
--- a/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php
+++ b/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php
@@ -21,15 +21,23 @@ class CompanyValidation extends AbstractValidation
}
/**
+ * @param string $type
* @return array
*/
- protected function rules(): array
+ protected function rules(?string $type = 'POST'): array
{
- return [
- 'company_name' => 'required',
- 'company_reference' => '',
- 'type' => 'required'
- ];
+ if ($type == 'POST') {
+ return [
+ 'company_name' => 'required',
+ 'company_reference' => '',
+ 'type' => ''
+ ];
+ }
+ elseif($type == 'PUT') {
+ return [
+ 'type' => 'required'
+ ];
+ }
}
/**
diff --git a/app/Classes/Modules/Documents/DataTransferObjects/DocumentObject.php b/app/Classes/Modules/Documents/DataTransferObjects/DocumentObject.php
new file mode 100644
index 00000000..2510f084
--- /dev/null
+++ b/app/Classes/Modules/Documents/DataTransferObjects/DocumentObject.php
@@ -0,0 +1,139 @@
+owner_id = $owner_id;
+ $this->owner_type = $owner_type;
+ $this->document_type = $document_type;
+ $this->reference = $reference;
+ $this->status = $status;
+ $this->approved_by = $approved_by;
+ $this->issued_date = $issued_date;
+ $this->expired_date = $expired_date;
+ $this->approved_date = $approved_date;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getOwnerId(): ?int
+ {
+ return $this->owner_id;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getOwnerType(): ?int
+ {
+ return $this->owner_type;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getDocumentType(): ?string
+ {
+ return $this->document_type;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getReference(): ?string
+ {
+ return $this->reference;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getStatus(): ?int
+ {
+ return $this->status;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getApprovedBy(): ?int
+ {
+ return $this->approved_by;
+ }
+
+ /**
+ * @return timestamp|null
+ */
+ public function getIssuedDate(): ?timestamp
+ {
+ return $this->issued_date;
+ }
+
+ /**
+ * @return timestamp|null
+ */
+ public function getExpiredDate(): ?timestamp
+ {
+ return $this->expired_date;
+ }
+
+ /**
+ * @return timestamp|null
+ */
+ public function getApprovedDate(): ?timestamp
+ {
+ return $this->approved_date;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php
new file mode 100644
index 00000000..112ed3e1
--- /dev/null
+++ b/app/Classes/Modules/Documents/DataTransferObjects/FileObject.php
@@ -0,0 +1,59 @@
+document_id = $document_id;
+ $this->file = $file;
+ $this->file_type = $file_type;
+ }
+
+ /**
+ * @return int|null
+ */
+ public function getDocumentId(): ?int
+ {
+ return $this->document_id;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getFile(): ?string
+ {
+ return $this->file;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getFileType(): ?string
+ {
+ return $this->file_type;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Services/Convert64ToFile.php b/app/Classes/Modules/Documents/Services/Convert64ToFile.php
new file mode 100644
index 00000000..1976433d
--- /dev/null
+++ b/app/Classes/Modules/Documents/Services/Convert64ToFile.php
@@ -0,0 +1,146 @@
+generateFolder($path);
+
+ foreach ($file_set as $key => $row) {
+
+ $file_data = $row;
+ $filename = (string) Str::uuid();
+
+ $f = finfo_open();
+ $mime_type = finfo_file($f, $file_data, FILEINFO_MIME_TYPE);
+
+ $extension = '';
+ switch ($mime_type) {
+ case 'image/gif':
+ $extension = 'gif';
+ break;
+ case 'image/png':
+ $extension = 'png';
+ break;
+ case 'image/jpeg':
+ $extension = 'jpg';
+ break;
+ case 'application/pdf':
+ $extension = 'pdf';
+ break;
+ }
+
+ if (empty($extension)) {
+ return false;
+ }
+
+ $filename_with_ext = $filename . '.' . $extension;
+
+ if ($extension != 'pdf') {
+ $img = Image::make($file_data)->save($folder_path . '/' . $filename_with_ext);
+ $file = $this->generateImages($path, $filename_with_ext, $filename, $extension);
+ }
+ else {
+ $file_data = explode('base64,', $file_data);
+ $file_data = base64_decode($file_data[1]);
+ $file = $this->generatePdf($path, $file_data, $filename, $extension);
+ }
+
+ $file_info[] = [
+ 'path' => $path,
+ 'filename' => $filename_with_ext,
+ 'mime_type' => $mime_type,
+ 'extension' => $extension,
+ 'file_info' => empty($file) ? [] : $file,
+ ];
+ }
+
+ return $file_info;
+ }
+
+ /**
+ * @param string|null path
+ * @param string|null pdfdata
+ * @param string|null filename
+ * @param string|null extension
+ */
+ public static function generatePdf($path = '', $pdfdata = '', $filename = '', $extension = '')
+ {
+ $file_info = [];
+ $file = \File::put(storage_path($path) . '/' . $filename . '.' . $extension, $pdfdata);
+ $file_info['original']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
+ $file_info['large']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
+ $file_info['medium']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
+ $file_info['small']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
+
+ return $file_info;
+ }
+
+ /**
+ * @param string|null path
+ * @param string|null file
+ * @param string|null filename
+ * @param string|null extension
+ */
+ public function generateImages($path = '', $file = '', $filename = '', $extension = '')
+ {
+ $file_info = [];
+
+ $img = Image::make(storage_path($path) . '/' . $file);
+ $file_info['original']['file'] = 'storage/' . $path . '/' . $file;
+ $file_info['original']['width'] = $img->width();
+ $file_info['original']['height'] = $img->height();
+
+ $img->widen(800, function ($constraint) {
+ $constraint->upsize();
+ })->heighten(800, function ($constraint) {
+ $constraint->upsize();
+ });
+ $img->save(storage_path($path) . '/' . $filename . '_' . 'l.' . $extension);
+ $file_info['large']['file'] = 'storage/' . $path . '/' . $filename . '_' . 'l.' . $extension;
+ $file_info['large']['width'] = $img->width();
+ $file_info['large']['height'] = $img->height();
+
+ $img->widen(480, function ($constraint) {
+ $constraint->upsize();
+ })->heighten(480, function ($constraint) {
+ $constraint->upsize();
+ });
+ $img->save(storage_path($path) . '/' . $filename . '_' . 'm.' . $extension);
+ $file_info['medium']['file'] = 'storage/' . $path . '/' . $filename . '_' . 'm.' . $extension;
+ $file_info['medium']['width'] = $img->width();
+ $file_info['medium']['height'] = $img->height();
+
+ $img->widen(320, function ($constraint) {
+ $constraint->upsize();
+ })->heighten(320, function ($constraint) {
+ $constraint->upsize();
+ });
+ $img->save(storage_path($path) . '/' . $filename . '_' . 's.' . $extension);
+ $file_info['small']['file'] = 'storage/' . $path . '/' . $filename . '_' . 's.' . $extension;
+ $file_info['small']['width'] = $img->width();
+ $file_info['small']['height'] = $img->height();
+
+ return $file_info;
+ }
+
+ /**
+ * @param string|null set_path
+ */
+ public function generateFolder($set_path = '')
+ {
+ $folder = storage_path($set_path);
+
+ \File::isDirectory($folder) or \File::makeDirectory($folder, 0777, true, true); //check folder is exist
+ return $folder;
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Services/CreatesDocument.php b/app/Classes/Modules/Documents/Services/CreatesDocument.php
new file mode 100644
index 00000000..33f4523c
--- /dev/null
+++ b/app/Classes/Modules/Documents/Services/CreatesDocument.php
@@ -0,0 +1,27 @@
+owner_id = $object->getOwnerId();
+ $model->owner_type = $object->getOwnerType();
+ $model->document_type = $object->getDocumentType();
+ $model->reference = $object->getReference();
+ $model->status = $object->getStatus();
+
+ return $this->handler($model);
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Services/CreatesFile.php b/app/Classes/Modules/Documents/Services/CreatesFile.php
new file mode 100644
index 00000000..ac87eb72
--- /dev/null
+++ b/app/Classes/Modules/Documents/Services/CreatesFile.php
@@ -0,0 +1,25 @@
+document_id = $object->getDocumentId();
+ $model->file = $object->getFile();
+ $model->file_type = $object->getFileType();
+
+ return $this->handler($model);
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Standards/Rules/CanCreateDocument.php b/app/Classes/Modules/Documents/Standards/Rules/CanCreateDocument.php
new file mode 100644
index 00000000..abac99e3
--- /dev/null
+++ b/app/Classes/Modules/Documents/Standards/Rules/CanCreateDocument.php
@@ -0,0 +1,53 @@
+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;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Standards/Rules/CanCreateFile.php b/app/Classes/Modules/Documents/Standards/Rules/CanCreateFile.php
new file mode 100644
index 00000000..d029cf2a
--- /dev/null
+++ b/app/Classes/Modules/Documents/Standards/Rules/CanCreateFile.php
@@ -0,0 +1,53 @@
+fileValidation = $fileValidation;
+ }
+
+ /**
+ * @return bool
+ */
+ protected function authorized(): bool
+ {
+ // TODO Set Authorization rules
+ return true;
+ }
+
+ /**
+ * @param FileObject $object
+ * @return bool
+ * @throws \App\Classes\Exceptions\RequestValidationException
+ */
+ protected function validators($object): bool
+ {
+ return $this->fileValidation->validate($object);
+ }
+
+ /**
+ * @param FileObject $object
+ * @return bool
+ */
+ protected function criteria($object): bool
+ {
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Standards/Validators/DocumentValidation.php b/app/Classes/Modules/Documents/Standards/Validators/DocumentValidation.php
new file mode 100644
index 00000000..9ff7ef03
--- /dev/null
+++ b/app/Classes/Modules/Documents/Standards/Validators/DocumentValidation.php
@@ -0,0 +1,53 @@
+ $object->getOwnerId(),
+ 'owner_type' => $object->getOwnerType(),
+ 'document_type' => $object->getDocumentType(),
+ 'reference' => $object->getReference(),
+ 'status' => $object->getStatus(),
+ 'approved_by' => $object->getApprovedBy(),
+ 'issued_date' => $object->getIssuedDate(),
+ 'expired_date' => $object->getExpiredDate(),
+ 'approved_date' => $object->getApprovedDate()
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function rules(): array
+ {
+ return [
+ 'owner_id' => 'required',
+ 'owner_type' => 'required',
+ 'document_type' => 'required',
+ 'reference' => 'required',
+ 'status' => '',
+ 'issued_date' => '',
+ 'expired_date' => '',
+ 'approved_date' => '',
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function messages(): array
+ {
+ return [];
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/Modules/Documents/Standards/Validators/FileValidation.php b/app/Classes/Modules/Documents/Standards/Validators/FileValidation.php
new file mode 100644
index 00000000..3c429714
--- /dev/null
+++ b/app/Classes/Modules/Documents/Standards/Validators/FileValidation.php
@@ -0,0 +1,42 @@
+ $object->getDocumentId(),
+ 'file' => $object->getFile(),
+ 'file_type' => $object->getFileType()
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function rules(): array
+ {
+ return [
+ 'document_id' => 'required',
+ 'file' => 'required',
+ 'file_type' => 'required'
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function messages(): array
+ {
+ return [];
+ }
+}
\ No newline at end of file
diff --git a/app/Classes/ValueObjects/Constants/CompanyType.php b/app/Classes/ValueObjects/Constants/CompanyType.php
new file mode 100644
index 00000000..e1a763bb
--- /dev/null
+++ b/app/Classes/ValueObjects/Constants/CompanyType.php
@@ -0,0 +1,8 @@
+execute($request);
}
-
}
\ No newline at end of file
diff --git a/app/Http/Controllers/Accounts/RegistrationStep2Controller.php b/app/Http/Controllers/Accounts/RegistrationStep2Controller.php
new file mode 100644
index 00000000..2b2aa9ec
--- /dev/null
+++ b/app/Http/Controllers/Accounts/RegistrationStep2Controller.php
@@ -0,0 +1,19 @@
+execute($request);
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Accounts/UpdateUserController.php b/app/Http/Controllers/Accounts/UpdateUserController.php
new file mode 100644
index 00000000..d6d873a0
--- /dev/null
+++ b/app/Http/Controllers/Accounts/UpdateUserController.php
@@ -0,0 +1,19 @@
+execute($request);
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/Accounts/UserAuthenticationController.php b/app/Http/Controllers/Accounts/UserAuthenticationController.php
index df63d703..fdf4442d 100644
--- a/app/Http/Controllers/Accounts/UserAuthenticationController.php
+++ b/app/Http/Controllers/Accounts/UserAuthenticationController.php
@@ -1,6 +1,6 @@
hasMany(PasswordReset::class, 'user_id', 'id');
}
- public function employers(): belongsToMany {
- return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_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');
- }
+ // public function tweets(): hasMany {
+ // return $this->hasMany(Order::class, 'user_id', 'id');
+ // }
/**
@@ -68,6 +68,6 @@ class User extends AbstractModel implements
*/
public function company(): belongsToMany
{
- return $this->belongsToMany(Company::class, 'company_employee');
+ return $this->belongsToMany(Company::class, 'company_employee', 'user_id', 'company_id');
}
}
diff --git a/composer.json b/composer.json
index 3c4ee5c9..5aab2193 100644
--- a/composer.json
+++ b/composer.json
@@ -13,6 +13,7 @@
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
+ "intervention/image": "^2.5",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"spatie/laravel-activitylog": "^3.14",
diff --git a/composer.lock b/composer.lock
index 9b3cfaf7..58a33f43 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "f218c85b341310aa83abf66de10c33ab",
+ "content-hash": "2cb6e433182b50af0d18e09467a05407",
"packages": [
{
"name": "asm89/stack-cors",
@@ -699,6 +699,76 @@
],
"time": "2020-09-30T07:37:11+00:00"
},
+ {
+ "name": "intervention/image",
+ "version": "2.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Intervention/image.git",
+ "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
+ "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
+ "shasum": ""
+ },
+ "require": {
+ "ext-fileinfo": "*",
+ "guzzlehttp/psr7": "~1.1",
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "~0.9.2",
+ "phpunit/phpunit": "^4.8 || ^5.7"
+ },
+ "suggest": {
+ "ext-gd": "to use GD library based image processing.",
+ "ext-imagick": "to use Imagick based image processing.",
+ "intervention/imagecache": "Caching extension for the Intervention Image library"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ },
+ "laravel": {
+ "providers": [
+ "Intervention\\Image\\ImageServiceProvider"
+ ],
+ "aliases": {
+ "Image": "Intervention\\Image\\Facades\\Image"
+ }
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Intervention\\Image\\": "src/Intervention/Image"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Oliver Vogel",
+ "email": "oliver@olivervogel.com",
+ "homepage": "http://olivervogel.com/"
+ }
+ ],
+ "description": "Image handling and manipulation library with support for Laravel integration",
+ "homepage": "http://image.intervention.io/",
+ "keywords": [
+ "gd",
+ "image",
+ "imagick",
+ "laravel",
+ "thumbnail",
+ "watermark"
+ ],
+ "time": "2019-11-02T09:15:47+00:00"
+ },
{
"name": "laravel/framework",
"version": "v7.28.4",
diff --git a/database/migrations/2014_10_11_100012_create_states_table.php b/database/migrations/2014_10_11_100012_create_states_table.php
index 2e038b34..e3c89c1d 100644
--- a/database/migrations/2014_10_11_100012_create_states_table.php
+++ b/database/migrations/2014_10_11_100012_create_states_table.php
@@ -18,6 +18,7 @@ class CreateStatesTable extends Migration
$table->bigInteger('country_id')->unsigned()->nullable();
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
$table->string('name')->nullable();
+ $table->integer('status')->nullable();
$table->timestamps();
$table->softDeletes();
});
diff --git a/database/migrations/2014_10_11_100013_create_districts_table.php b/database/migrations/2014_10_11_100013_create_districts_table.php
index 80f800df..42da9530 100644
--- a/database/migrations/2014_10_11_100013_create_districts_table.php
+++ b/database/migrations/2014_10_11_100013_create_districts_table.php
@@ -21,6 +21,7 @@ class CreateDistrictsTable extends Migration
$table->foreign('state_id')->references('id')->on('states')->onDelete('cascade');
$table->string('name')->nullable();
$table->text('postcode')->nullable();
+ $table->integer('status')->nullable();
$table->timestamps();
$table->softDeletes();
});
diff --git a/database/migrations/2020_10_22_071102_create_companies_table.php b/database/migrations/2020_10_22_071102_create_companies_table.php
index ba8a3c47..aefff45d 100644
--- a/database/migrations/2020_10_22_071102_create_companies_table.php
+++ b/database/migrations/2020_10_22_071102_create_companies_table.php
@@ -19,6 +19,7 @@ class CreateCompaniesTable extends Migration
$table->string('reference')->nullable();
$table->integer('type')->nullable();
$table->timestamps();
+ $table->softDeletes();
});
}
diff --git a/database/migrations/2020_11_03_122319_create_documents_table.php b/database/migrations/2020_11_03_122319_create_documents_table.php
new file mode 100644
index 00000000..e81aefb7
--- /dev/null
+++ b/database/migrations/2020_11_03_122319_create_documents_table.php
@@ -0,0 +1,42 @@
+id();
+ $table->integer('owner_id')->nullable();
+ $table->integer('owner_type')->nullable();
+ $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->timestamp('issued_date')->nullable();
+ $table->timestamp('expired_date')->nullable();
+ $table->timestamp('approved_date')->nullable();
+ $table->timestamps();
+ $table->softDeletes();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('documents');
+ }
+}
diff --git a/database/migrations/2020_11_03_122358_create_files_table.php b/database/migrations/2020_11_03_122358_create_files_table.php
new file mode 100644
index 00000000..483f0f4e
--- /dev/null
+++ b/database/migrations/2020_11_03_122358_create_files_table.php
@@ -0,0 +1,36 @@
+id();
+ $table->bigInteger('document_id')->unsigned();
+ $table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade');
+ $table->text('file')->nullable();
+ $table->string('file_type')->nullable();
+ $table->timestamps();
+ $table->softDeletes();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('files');
+ }
+}
diff --git a/database/seeds/CountriesTableSeeder.php b/database/seeds/CountriesTableSeeder.php
index a272f94f..f2548290 100644
--- a/database/seeds/CountriesTableSeeder.php
+++ b/database/seeds/CountriesTableSeeder.php
@@ -18,7 +18,6 @@ class CountriesTableSeeder extends Seeder
'name' => 'Malaysia',
'short_code' => 'MY',
'phone_code' => '60',
- 'status' => 1,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]
diff --git a/database/seeds/CurrenciesTableSeeder.php b/database/seeds/CurrenciesTableSeeder.php
index c8ca2dec..dde39abf 100644
--- a/database/seeds/CurrenciesTableSeeder.php
+++ b/database/seeds/CurrenciesTableSeeder.php
@@ -19,7 +19,6 @@ class CurrenciesTableSeeder extends Seeder
'name' => 'Ringgit',
'short_code' => 'MYR',
'symbol' => 'RM',
- 'status' => 1,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]
diff --git a/resources/assets/sass/_responsive.scss b/resources/assets/sass/_responsive.scss
index 33498b91..622c734a 100644
--- a/resources/assets/sass/_responsive.scss
+++ b/resources/assets/sass/_responsive.scss
@@ -1131,4 +1131,57 @@
.hidden-xs {
display: none;
}
+}
+
+
+.upload-box {
+ width: 250px;
+ /*margin: auto;*/
+ position: relative;
+}
+
+.file-container {
+ overflow: hidden;
+ position: relative;
+}
+
+.file-container [type=file] {
+ cursor: inherit;
+ display: block;
+ filter: alpha(opacity=0);
+ min-height: 100%;
+ min-width: 100%;
+ opacity: 0;
+ position: absolute;
+ right: 0;
+ text-align: right;
+ top: 0;
+}
+
+.file-container {
+ text-align: center;
+ border: 1px dashed #d9d9d9;
+ background: #f3f3f4;
+ /*border-radius: 10px;*/
+ /* float: left; */
+ padding: .5em;
+}
+
+.file-container:hover {
+ border-color: #1AB394;
+}
+
+.file-container [type=file] {
+ cursor: pointer;
+}
+
+.upload-img {
+ margin: 0 !important;
+}
+
+.upload-img img {
+ width: 100%;
+ border: 1px solid #d9d9d9;
+ border-top: none;
+ pointer-events: none;
}
\ No newline at end of file
diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue
index 26e5c5ce..98aa3746 100644
--- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue
+++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue
@@ -80,7 +80,6 @@
successHandler(response){
localStorage.setItem('user-token', 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(){
diff --git a/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue b/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue
index dc50925e..d6e55e09 100644
--- a/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue
+++ b/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue
@@ -81,7 +81,7 @@
this.submit((this.route('api.account.registration')), 'post', 'registrationSection', true, true)
},
errorHandler(){
- console.log('nononon');
+
},
successHandler(){
console.log('yess');
diff --git a/resources/assets/vue/components/accounts/forms/RegistrationStep2FormComponent.vue b/resources/assets/vue/components/accounts/forms/RegistrationStep2FormComponent.vue
new file mode 100644
index 00000000..f0429fc9
--- /dev/null
+++ b/resources/assets/vue/components/accounts/forms/RegistrationStep2FormComponent.vue
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
Registration Step 2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/pages/accounts/registration_step_2.blade.php b/resources/views/pages/accounts/registration_step_2.blade.php
new file mode 100644
index 00000000..8f6ff010
--- /dev/null
+++ b/resources/views/pages/accounts/registration_step_2.blade.php
@@ -0,0 +1,4 @@
+@extends('layouts.base_login')
+@section('inner_content')
+
+@endSection
\ No newline at end of file
diff --git a/routes/account.php b/routes/account.php
index c2dacf1c..76c96fa8 100644
--- a/routes/account.php
+++ b/routes/account.php
@@ -7,7 +7,7 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () {
Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () {
- Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
+ Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
});
// Route::group(['prefix' => 'password', 'as' => 'password.'], function () {
@@ -15,7 +15,10 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
// Route::post('/reset', 'ResetPasswordController@reset')->name('reset');
// });
-
+ });
+
+ Route::group(['middleware' => 'valid.token'], function () {
+ Route::post('/registration-setp-2', 'RegistrationStep2Controller@create')->name('registration-step-2');
});
Route::post('/registration', 'CreateUserController@create')->name('registration');
diff --git a/routes/web.php b/routes/web.php
index 6d424aff..1c0aaa42 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -20,12 +20,17 @@ Route::get('', function () {
Route::get('account/registration', function () {
return view('pages.accounts.registration');
-})->name('login');
+})->name('registration');
+
+Route::get('account/registration-step-2', function () {
+ return view('pages.accounts.registration_step_2');
+})->name('registration-step-2');
+
Route::get('account/password/reset/{token}', function ($token){
return view('pages.accounts.authentication.reset_password',['token' => $token]);
})->name('account.password.reset');
route::get('dashboard/', function (){
- return 'dashboard page here';
+ return redirect()->route('registration-step-2');
})->name('dashboard');