From b7e995c088e30ac85bc9fb7ae69d70252982f4ff Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Mon, 2 Nov 2020 12:48:44 +0800 Subject: [PATCH 1/4] pull --- .../vue/components/accounts/forms/RegistrationFormComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'); From 2bf5de8f3e922501e495e7eda1406a639486b1ad Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Tue, 3 Nov 2020 21:03:33 +0800 Subject: [PATCH 2/4] migrate Document & Content point constant --- .../ControllerLogic/CreateUserLogic.php | 2 +- .../DataTransferObjects/CompanyObject.php | 2 +- .../Validators/CompanyValidation.php | 2 +- .../ValueObjects/Constants/CompanyType.php | 8 ++++ .../ValueObjects/Constants/DocumentTypes.php | 8 ++++ .../ValueObjects/Constants/QwnerTypes.php | 7 ++++ .../Accounts/UserAuthenticationController.php | 2 +- app/Models/Content.php | 24 +++++++++++ app/Models/Document.php | 26 ++++++++++++ .../2014_10_11_100012_create_states_table.php | 1 + ...14_10_11_100013_create_districts_table.php | 1 + ...20_11_03_122319_create_documents_table.php | 42 +++++++++++++++++++ ...020_11_03_122358_create_contents_table.php | 36 ++++++++++++++++ database/seeds/CountriesTableSeeder.php | 1 - database/seeds/CurrenciesTableSeeder.php | 1 - routes/web.php | 2 +- 16 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 app/Classes/ValueObjects/Constants/CompanyType.php create mode 100644 app/Classes/ValueObjects/Constants/DocumentTypes.php create mode 100644 app/Classes/ValueObjects/Constants/QwnerTypes.php create mode 100644 app/Models/Content.php create mode 100644 app/Models/Document.php create mode 100644 database/migrations/2020_11_03_122319_create_documents_table.php create mode 100644 database/migrations/2020_11_03_122358_create_contents_table.php 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/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/Standards/Validators/CompanyValidation.php b/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php index 0ecab47d..f7c6444e 100644 --- a/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php +++ b/app/Classes/Modules/Companies/Standards/Validators/CompanyValidation.php @@ -28,7 +28,7 @@ class CompanyValidation extends AbstractValidation return [ 'company_name' => 'required', 'company_reference' => '', - 'type' => 'required' + 'type' => '' ]; } 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 @@ +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_11_03_122319_create_documents_table.php b/database/migrations/2020_11_03_122319_create_documents_table.php new file mode 100644 index 00000000..677c6d4c --- /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->integer('document_type')->nullable(); + $table->integer('status')->nullable(); + $table->string('reference')->nullable(); + $table->bigInteger('approved_by')->unsigned(); + $table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade'); + $table->timestamp('issued_date')->nullable(); + $table->timestamp('expired_date')->nullable(); + $table->timestamp('approved_date')->nullable(); + $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_contents_table.php b/database/migrations/2020_11_03_122358_create_contents_table.php new file mode 100644 index 00000000..4f39731a --- /dev/null +++ b/database/migrations/2020_11_03_122358_create_contents_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->integer('file_type_id')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('contents'); + } +} 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/routes/web.php b/routes/web.php index 6d424aff..b4758315 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,7 +20,7 @@ Route::get('', function () { Route::get('account/registration', function () { return view('pages.accounts.registration'); -})->name('login'); +})->name('registration'); Route::get('account/password/reset/{token}', function ($token){ return view('pages.accounts.authentication.reset_password',['token' => $token]); From a2381e44a719006bfded1f50456a20b2a7bf96b7 Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Thu, 5 Nov 2020 14:51:56 +0800 Subject: [PATCH 3/4] User Registration Step 2 Logic Class Update Company Service Class Create Documents Service Class Create File Service Class Base64 File Convert Service Class File Upload Storage Service Class --- .gitignore | 1 + .../General/Abstracts/AbstractValidation.php | 6 +- .../ControllerLogic/UpdateUserLogic.php | 158 ++++++++++++++++++ .../Modules/Accounts/Services/FetchesUser.php | 33 ++++ .../Companies/Services/UpdatesCompany.php | 25 +++ .../Standards/Rules/CanUpdateCompany.php | 50 ++++++ .../Validators/CompanyValidation.php | 20 ++- .../DataTransferObjects/DocumentObject.php | 139 +++++++++++++++ .../DataTransferObjects/FileObject.php | 59 +++++++ .../Documents/Services/Convert64ToFile.php | 146 ++++++++++++++++ .../Documents/Services/CreatesDocument.php | 27 +++ .../Documents/Services/CreatesFile.php | 25 +++ .../Standards/Rules/CanCreateDocument.php | 53 ++++++ .../Standards/Rules/CanCreateFile.php | 53 ++++++ .../Validators/DocumentValidation.php | 53 ++++++ .../Standards/Validators/FileValidation.php | 42 +++++ .../ValueObjects/Constants/DocumentType.php | 8 + .../ValueObjects/Constants/DocumentTypes.php | 8 - .../ValueObjects/Constants/FileType.php | 8 + .../ValueObjects/Constants/ObjectStatus.php | 7 + .../{QwnerTypes.php => OwnerType.php} | 2 +- .../Accounts/CreateUserController.php | 1 - .../Accounts/UpdateUserController.php | 19 +++ app/Models/Document.php | 2 +- app/Models/{Content.php => File.php} | 6 +- app/Models/User.php | 14 +- composer.json | 1 + composer.lock | 72 +++++++- ...20_10_22_071102_create_companies_table.php | 1 + ...20_11_03_122319_create_documents_table.php | 6 +- ... 2020_11_03_122358_create_files_table.php} | 8 +- .../accounts/forms/LoginFormComponent.vue | 4 +- routes/account.php | 8 +- 33 files changed, 1025 insertions(+), 40 deletions(-) create mode 100644 app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php create mode 100644 app/Classes/Modules/Accounts/Services/FetchesUser.php create mode 100644 app/Classes/Modules/Companies/Services/UpdatesCompany.php create mode 100644 app/Classes/Modules/Companies/Standards/Rules/CanUpdateCompany.php create mode 100644 app/Classes/Modules/Documents/DataTransferObjects/DocumentObject.php create mode 100644 app/Classes/Modules/Documents/DataTransferObjects/FileObject.php create mode 100644 app/Classes/Modules/Documents/Services/Convert64ToFile.php create mode 100644 app/Classes/Modules/Documents/Services/CreatesDocument.php create mode 100644 app/Classes/Modules/Documents/Services/CreatesFile.php create mode 100644 app/Classes/Modules/Documents/Standards/Rules/CanCreateDocument.php create mode 100644 app/Classes/Modules/Documents/Standards/Rules/CanCreateFile.php create mode 100644 app/Classes/Modules/Documents/Standards/Validators/DocumentValidation.php create mode 100644 app/Classes/Modules/Documents/Standards/Validators/FileValidation.php create mode 100644 app/Classes/ValueObjects/Constants/DocumentType.php delete mode 100644 app/Classes/ValueObjects/Constants/DocumentTypes.php create mode 100644 app/Classes/ValueObjects/Constants/FileType.php create mode 100644 app/Classes/ValueObjects/Constants/ObjectStatus.php rename app/Classes/ValueObjects/Constants/{QwnerTypes.php => OwnerType.php} (75%) create mode 100644 app/Http/Controllers/Accounts/UpdateUserController.php rename app/Models/{Content.php => File.php} (80%) rename database/migrations/{2020_11_03_122358_create_contents_table.php => 2020_11_03_122358_create_files_table.php} (76%) 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/UpdateUserLogic.php b/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php new file mode 100644 index 00000000..f40a527c --- /dev/null +++ b/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php @@ -0,0 +1,158 @@ + '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) { + dd($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/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 f7c6444e..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' => '' - ]; + 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/DocumentType.php b/app/Classes/ValueObjects/Constants/DocumentType.php new file mode 100644 index 00000000..4b82f8c4 --- /dev/null +++ b/app/Classes/ValueObjects/Constants/DocumentType.php @@ -0,0 +1,8 @@ +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/Models/Document.php b/app/Models/Document.php index 74ad1a88..6c48c2c8 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.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/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 index 677c6d4c..e81aefb7 100644 --- a/database/migrations/2020_11_03_122319_create_documents_table.php +++ b/database/migrations/2020_11_03_122319_create_documents_table.php @@ -17,11 +17,11 @@ class CreateDocumentsTable extends Migration $table->id(); $table->integer('owner_id')->nullable(); $table->integer('owner_type')->nullable(); - $table->integer('document_type')->nullable(); - $table->integer('status')->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'); + $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(); diff --git a/database/migrations/2020_11_03_122358_create_contents_table.php b/database/migrations/2020_11_03_122358_create_files_table.php similarity index 76% rename from database/migrations/2020_11_03_122358_create_contents_table.php rename to database/migrations/2020_11_03_122358_create_files_table.php index 4f39731a..483f0f4e 100644 --- a/database/migrations/2020_11_03_122358_create_contents_table.php +++ b/database/migrations/2020_11_03_122358_create_files_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateContentsTable extends Migration +class CreateFilesTable extends Migration { /** * Run the migrations. @@ -13,12 +13,12 @@ class CreateContentsTable extends Migration */ public function up() { - Schema::create('contents', function (Blueprint $table) { + Schema::create('files', function (Blueprint $table) { $table->id(); $table->bigInteger('document_id')->unsigned(); $table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade'); $table->text('file')->nullable(); - $table->integer('file_type_id')->nullable(); + $table->string('file_type')->nullable(); $table->timestamps(); $table->softDeletes(); }); @@ -31,6 +31,6 @@ class CreateContentsTable extends Migration */ public function down() { - Schema::dropIfExists('contents'); + Schema::dropIfExists('files'); } } diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue index 26e5c5ce..d0842ccc 100644 --- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -79,12 +79,14 @@ 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; + // window.location.href = response.payload.redirect_url; }, 2000); }, errorHandler(error){ diff --git a/routes/account.php b/routes/account.php index c2dacf1c..176023d5 100644 --- a/routes/account.php +++ b/routes/account.php @@ -7,9 +7,11 @@ 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 () { // Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget'); // Route::post('/reset', 'ResetPasswordController@reset')->name('reset'); @@ -17,6 +19,10 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account }); + + Route::group(['middleware' => 'valid.token'], function () { + Route::post('/registration-setp-2', 'UpdateUserController@update')->name('registration'); + }); Route::post('/registration', 'CreateUserController@create')->name('registration'); From 6b394420dcaf65d8fae8bfb7f4affcfb2d22361e Mon Sep 17 00:00:00 2001 From: CheeSiong Date: Fri, 6 Nov 2020 15:26:53 +0800 Subject: [PATCH 4/4] registration step 2 front end --- .../RegistrationStep2Logic.php | 157 ++++++++++++++++++ .../ControllerLogic/UpdateUserLogic.php | 1 - .../Accounts/RegistrationStep2Controller.php | 19 +++ resources/assets/sass/_responsive.scss | 53 ++++++ .../accounts/forms/LoginFormComponent.vue | 5 +- .../forms/RegistrationStep2FormComponent.vue | 122 ++++++++++++++ .../accounts/registration_step_2.blade.php | 4 + routes/account.php | 5 +- routes/web.php | 7 +- 9 files changed, 363 insertions(+), 10 deletions(-) create mode 100644 app/Classes/Modules/Accounts/ControllerLogic/RegistrationStep2Logic.php create mode 100644 app/Http/Controllers/Accounts/RegistrationStep2Controller.php create mode 100644 resources/assets/vue/components/accounts/forms/RegistrationStep2FormComponent.vue create mode 100644 resources/views/pages/accounts/registration_step_2.blade.php 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 index f40a527c..e28e7a35 100644 --- a/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllerLogic/UpdateUserLogic.php @@ -150,7 +150,6 @@ class UpdateUserLogic extends AbstractControllerLogic return $this->resourceResponse(new UserResource(\Auth::user())); } catch (\Exception $exception) { - dd($exception); throw new ErrorException($exception->getMessage(), $exception->getCode()); } 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/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 d0842ccc..98aa3746 100644 --- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -79,14 +79,11 @@ 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; + window.location.href = response.payload.redirect_url; }, 2000); }, errorHandler(error){ 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 @@ + + 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 176023d5..76c96fa8 100644 --- a/routes/account.php +++ b/routes/account.php @@ -10,18 +10,15 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt'); }); - - // Route::group(['prefix' => 'password', 'as' => 'password.'], function () { // Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget'); // Route::post('/reset', 'ResetPasswordController@reset')->name('reset'); // }); - }); Route::group(['middleware' => 'valid.token'], function () { - Route::post('/registration-setp-2', 'UpdateUserController@update')->name('registration'); + 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 b4758315..1c0aaa42 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,10 +22,15 @@ Route::get('account/registration', function () { return view('pages.accounts.registration'); })->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');