From 7f712e6ca895edf2e50dd7998619c7f72e18a992 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Mon, 24 Aug 2020 09:54:49 +0800 Subject: [PATCH] bulk commit --- .../Scaffold/ControllerLogicGenerator.php | 6 +- .../Controllers/create_controller.stub | 2 +- .../Controllers/delete_controller.stub | 2 +- .../Controllers/fetch_controller.stub | 2 +- .../Scaffold/Controllers/list_controller.stub | 2 +- .../Controllers/update_controller.stub | 2 +- .../General/Eloquent/AbstractUpdateRecord.php | 7 +- .../AuthenticateUserLogic.php | 7 +- .../ControllersLogic/CreateUserLogic.php | 129 +++++++++++ ...ControllerLogic.php => ListUsersLogic.php} | 2 +- .../RegistrationObject.php | 71 ++++++ .../Modules/Accounts/Services/CreatesUser.php | 30 +++ .../Standards/Rules/CanCreateUser.php | 58 +++++ .../Validators/UserRegistrationValidation.php | 48 +++++ .../CreateAddressLogic.php} | 4 +- .../DeleteAddressLogic.php} | 4 +- .../FetchAddressLogic.php} | 4 +- .../ListAddressesLogic.php} | 6 +- .../UpdateAddressLogic.php} | 6 +- .../Addresses/Services/CreatesAddress.php | 5 + .../Addresses/Services/UpdatesAddress.php | 6 + .../CreateCompanyControllerLogic.php | 69 ------ .../ControllersLogic/CreateCompanyLogic.php | 55 +++++ .../DeleteCompanyLogic.php} | 6 +- .../FetchCompanyLogic.php} | 4 +- .../ListCompaniesLogic.php} | 4 +- .../UpdateCompanyLogic.php} | 4 +- .../DataTransferObjects/CompanyObject.php | 21 +- .../DataTransferObjects/ConnectionObject.php | 45 ++++ .../DataTransferObjects/EmployeeObject.php | 58 +++++ .../DataTransferObjects/ModuleObject.php | 44 ++++ .../Processors/CreateCompanyProcessor.php | 53 +++++ .../ChecksIfCompanyAccountNumberExists.php | 26 +++ .../Companies/Services/CreatesCompany.php | 5 + .../Services/CreatesCompanyConnection.php | 20 ++ .../Services/CreatesCompanyEmployee.php | 19 ++ .../Services/CreatesCompanyModule.php | 24 +++ .../Companies/Services/DeletesCompany.php | 5 + .../Services/GeneratesUniqueAccountNumber.php | 31 +++ .../Companies/Services/UpdatesCompany.php | 6 + .../CreateContactControllerLogic.php | 70 ------ .../ControllersLogic/CreateContactLogic.php | 55 +++++ .../DeleteContactLogic.php} | 4 +- .../FetchContactLogic.php} | 4 +- .../ListContactsLogic.php} | 4 +- .../UpdateContactLogic.php} | 4 +- .../Processors/CreateContactProcessor.php | 45 ++++ .../Contacts/Services/CreatesContact.php | 5 + .../Contacts/Services/UpdatesContact.php | 6 + .../ValueObjects/Constants/CompanyRoles.php | 11 + .../ValueObjects/Constants/CompanyTypes.php | 14 ++ .../Constants/ConnectionStatus.php | 17 ++ .../ValueObjects/Constants/ModularTypes.php | 26 --- .../ValueObjects/Constants/ModuleTypes.php | 13 ++ .../ValueObjects/Constants/Notifications.php | 5 + .../ValueObjects/Constants/RelationStatus.php | 17 ++ .../CheckEmailController.php | 2 +- .../Account/CreateUserController.php | 15 ++ .../GeneratePasswordResetController.php | 2 +- .../{User => }/ListUsersController.php | 6 +- .../ResetPasswordController.php | 2 +- .../UserAuthenticationController.php | 2 +- .../Addresses/CreateAddressController.php | 6 +- .../Addresses/DeleteAddressController.php | 6 +- .../Addresses/FetchAddressController.php | 6 +- .../Addresses/ListAddressesController.php | 6 +- .../Addresses/UpdateAddressController.php | 6 +- .../Companies/CreateCompanyController.php | 6 +- .../Companies/DeleteCompanyController.php | 6 +- .../Companies/FetchCompanyController.php | 6 +- .../Companies/ListCompaniesController.php | 6 +- .../Companies/UpdateCompanyController.php | 6 +- .../Contacts/CreateContactController.php | 6 +- .../Contacts/DeleteContactController.php | 6 +- .../Contacts/FetchContactController.php | 6 +- .../Contacts/ListContactsController.php | 6 +- .../Contacts/UpdateContactController.php | 6 +- app/Models/Address.php | 49 +---- app/Models/Company.php | 58 ++--- app/Models/CompanyConnections.php | 36 ++++ app/Models/CompanyEmployee.php | 47 ++++ app/Models/CompanyModule.php | 60 ++++++ app/Models/Contact.php | 36 +--- app/Models/Order.php | 16 -- app/Models/PasswordReset.php | 11 +- app/Models/User.php | 33 +-- database/factories/CompanyFactory.php | 4 +- .../2014_10_12_000000_create_users_table.php | 3 +- ..._create_user_email_verifications_table.php | 38 ++++ ...20_08_04_042142_create_companies_table.php | 5 +- ...04_042264_create_company_modules_table.php | 38 ++++ ...42683_create_company_connections_table.php | 45 ++++ ..._043286_create_company_employees_table.php | 42 ++++ .../2020_08_05_223808_create_order_table.php | 43 ---- .../2020_08_06_035532_create_orders_table.php | 8 +- database/seeds/AddressesTableSeeder.php | 4 +- database/seeds/CompaniesTableSeeder.php | 18 +- database/seeds/ContactsTableSeeder.php | 3 +- database/seeds/UsersTableSeeder.php | 12 +- .../forms/ForgetPasswordFormComponent.vue | 2 +- .../forms/LoginFormComponent.vue | 2 +- .../forms/RegistrationFormComponent.vue | 202 +++++++++++------- .../forms/ResetPasswordFormComponent.vue | 2 +- .../sections/LoginSectionComponent.vue | 31 ++- resources/assets/vue/mixins/requestMixin.js | 1 + .../assets/vue/vuex/modules/crudRequest.js | 4 + .../accounts/authentication/login.blade.php | 2 +- routes/account.php | 8 +- 108 files changed, 1601 insertions(+), 583 deletions(-) create mode 100644 app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php rename app/Classes/Modules/Accounts/ControllersLogic/{ListUsersControllerLogic.php => ListUsersLogic.php} (96%) create mode 100644 app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php create mode 100644 app/Classes/Modules/Accounts/Services/CreatesUser.php create mode 100644 app/Classes/Modules/Accounts/Standards/Rules/CanCreateUser.php create mode 100644 app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php rename app/Classes/Modules/Addresses/{ControllerLogic/CreateAddressControllerLogic.php => ControllersLogic/CreateAddressLogic.php} (94%) rename app/Classes/Modules/Addresses/{ControllerLogic/DeleteAddressControllerLogic.php => ControllersLogic/DeleteAddressLogic.php} (93%) rename app/Classes/Modules/Addresses/{ControllerLogic/FetchAddressControllerLogic.php => ControllersLogic/FetchAddressLogic.php} (93%) rename app/Classes/Modules/Addresses/{ControllerLogic/ListAddressesControllerLogic.php => ControllersLogic/ListAddressesLogic.php} (90%) rename app/Classes/Modules/Addresses/{ControllerLogic/UpdateAddressControllerLogic.php => ControllersLogic/UpdateAddressLogic.php} (92%) delete mode 100644 app/Classes/Modules/Companies/ControllerLogic/CreateCompanyControllerLogic.php create mode 100644 app/Classes/Modules/Companies/ControllersLogic/CreateCompanyLogic.php rename app/Classes/Modules/Companies/{ControllerLogic/DeleteCompanyControllerLogic.php => ControllersLogic/DeleteCompanyLogic.php} (91%) rename app/Classes/Modules/Companies/{ControllerLogic/FetchCompanyControllerLogic.php => ControllersLogic/FetchCompanyLogic.php} (93%) rename app/Classes/Modules/Companies/{ControllerLogic/ListCompaniesControllerLogic.php => ControllersLogic/ListCompaniesLogic.php} (93%) rename app/Classes/Modules/Companies/{ControllerLogic/UpdateCompanyControllerLogic.php => ControllersLogic/UpdateCompanyLogic.php} (94%) create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/ConnectionObject.php create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/EmployeeObject.php create mode 100644 app/Classes/Modules/Companies/DataTransferObjects/ModuleObject.php create mode 100644 app/Classes/Modules/Companies/Processors/CreateCompanyProcessor.php create mode 100644 app/Classes/Modules/Companies/Services/ChecksIfCompanyAccountNumberExists.php create mode 100644 app/Classes/Modules/Companies/Services/CreatesCompanyConnection.php create mode 100644 app/Classes/Modules/Companies/Services/CreatesCompanyEmployee.php create mode 100644 app/Classes/Modules/Companies/Services/CreatesCompanyModule.php create mode 100644 app/Classes/Modules/Companies/Services/GeneratesUniqueAccountNumber.php delete mode 100644 app/Classes/Modules/Contacts/ControllerLogic/CreateContactControllerLogic.php create mode 100644 app/Classes/Modules/Contacts/ControllersLogic/CreateContactLogic.php rename app/Classes/Modules/Contacts/{ControllerLogic/DeleteContactControllerLogic.php => ControllersLogic/DeleteContactLogic.php} (93%) rename app/Classes/Modules/Contacts/{ControllerLogic/FetchContactControllerLogic.php => ControllersLogic/FetchContactLogic.php} (93%) rename app/Classes/Modules/Contacts/{ControllerLogic/ListContactsControllerLogic.php => ControllersLogic/ListContactsLogic.php} (93%) rename app/Classes/Modules/Contacts/{ControllerLogic/UpdateContactControllerLogic.php => ControllersLogic/UpdateContactLogic.php} (94%) create mode 100644 app/Classes/Modules/Contacts/Processors/CreateContactProcessor.php create mode 100644 app/Classes/ValueObjects/Constants/CompanyRoles.php create mode 100644 app/Classes/ValueObjects/Constants/CompanyTypes.php create mode 100644 app/Classes/ValueObjects/Constants/ConnectionStatus.php delete mode 100644 app/Classes/ValueObjects/Constants/ModularTypes.php create mode 100644 app/Classes/ValueObjects/Constants/ModuleTypes.php create mode 100644 app/Classes/ValueObjects/Constants/RelationStatus.php rename app/Http/Controllers/Account/{Authentication => }/CheckEmailController.php (88%) create mode 100644 app/Http/Controllers/Account/CreateUserController.php rename app/Http/Controllers/Account/{Authentication => }/GeneratePasswordResetController.php (89%) rename app/Http/Controllers/Account/{User => }/ListUsersController.php (68%) rename app/Http/Controllers/Account/{Authentication => }/ResetPasswordController.php (88%) rename app/Http/Controllers/Account/{Authentication => }/UserAuthenticationController.php (89%) create mode 100644 app/Models/CompanyConnections.php create mode 100644 app/Models/CompanyEmployee.php create mode 100644 app/Models/CompanyModule.php create mode 100644 database/migrations/2020_08_04_023621_create_user_email_verifications_table.php create mode 100644 database/migrations/2020_08_04_042264_create_company_modules_table.php create mode 100644 database/migrations/2020_08_04_042683_create_company_connections_table.php create mode 100644 database/migrations/2020_08_04_043286_create_company_employees_table.php delete mode 100644 database/migrations/2020_08_05_223808_create_order_table.php diff --git a/app/Classes/CodeGenerator/Generators/Scaffold/ControllerLogicGenerator.php b/app/Classes/CodeGenerator/Generators/Scaffold/ControllerLogicGenerator.php index 17230807..dd10bf31 100644 --- a/app/Classes/CodeGenerator/Generators/Scaffold/ControllerLogicGenerator.php +++ b/app/Classes/CodeGenerator/Generators/Scaffold/ControllerLogicGenerator.php @@ -23,7 +23,7 @@ class ControllerLogicGenerator extends BaseGenerator parent::__construct(); $this->commandData = $commandData; - $this->path = app_path('Classes/Modules/'. str::pluralStudly($this->commandData->modelName).'/ControllerLogic/'); + $this->path = app_path('Classes/Modules/'. str::pluralStudly($this->commandData->modelName).'/ControllersLogic/'); } public function generate() @@ -32,7 +32,7 @@ class ControllerLogicGenerator extends BaseGenerator foreach(['create', 'list', 'fetch', 'update', 'delete'] as $type){ $name = $type === 'list' ? str::pluralStudly($this->commandData->modelName) : str::singular($this->commandData->modelName); - $filename = str::studly($type.$name).'ControllerLogic.php'; + $filename = str::studly($type.$name).'Logic.php'; $templateData = $this->generatorHelpers->get_template("Scaffold.ControllersLogic.".$type."_controller_logic"); @@ -70,7 +70,7 @@ class ControllerLogicGenerator extends BaseGenerator foreach(['create', 'list', 'fetch', 'update', 'delete'] as $type){ $name = $type === 'list' ? str::pluralStudly($this->commandData->modelName) : str::singular($this->commandData->modelName); - $filename = str::studly($type.$name).'ControllerLogic.php'; + $filename = str::studly($type.$name).'Logic.php'; if ($this->rollbackFile($this->path, $filename)) { $this->commandData->commandComment($type . ' Controller logic file deleted: '.$filename); diff --git a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/create_controller.stub b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/create_controller.stub index e92041ab..50336e91 100644 --- a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/create_controller.stub +++ b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/create_controller.stub @@ -2,7 +2,7 @@ namespace App\Http\Controllers\$MODEL_NAME_PLURAL$; -use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Create$MODEL_NAME$ControllerLogic; +use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Create$MODEL_NAME$Logic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/delete_controller.stub b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/delete_controller.stub index cc654d6b..adaea8cb 100644 --- a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/delete_controller.stub +++ b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/delete_controller.stub @@ -2,7 +2,7 @@ namespace App\Http\Controllers\$MODEL_NAME_PLURAL$; -use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Delete$MODEL_NAME$ControllerLogic; +use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Delete$MODEL_NAME$Logic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/fetch_controller.stub b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/fetch_controller.stub index d967838b..a88e2c9e 100644 --- a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/fetch_controller.stub +++ b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/fetch_controller.stub @@ -2,7 +2,7 @@ namespace App\Http\Controllers\$MODEL_NAME_PLURAL$; -use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Fetch$MODEL_NAME$ControllerLogic; +use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Fetch$MODEL_NAME$Logic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/list_controller.stub b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/list_controller.stub index f2741e30..db3dd7dc 100644 --- a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/list_controller.stub +++ b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/list_controller.stub @@ -2,7 +2,7 @@ namespace App\Http\Controllers\$MODEL_NAME_PLURAL$; -use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\List$MODEL_NAME_PLURAL$ControllerLogic; +use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\List$MODEL_NAME_PLURAL$Logic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/update_controller.stub b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/update_controller.stub index 1ed56ee7..28629ddf 100644 --- a/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/update_controller.stub +++ b/app/Classes/CodeGenerator/Stubs/Scaffold/Controllers/update_controller.stub @@ -2,7 +2,7 @@ namespace App\Http\Controllers\$MODEL_NAME_PLURAL$; -use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Update$MODEL_NAME$ControllerLogic; +use App\Classes\Modules\$MODEL_NAME_PLURAL$\ControllerLogic\Update$MODEL_NAME$Logic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; diff --git a/app/Classes/General/Eloquent/AbstractUpdateRecord.php b/app/Classes/General/Eloquent/AbstractUpdateRecord.php index fae9d52d..de5730bd 100644 --- a/app/Classes/General/Eloquent/AbstractUpdateRecord.php +++ b/app/Classes/General/Eloquent/AbstractUpdateRecord.php @@ -11,12 +11,13 @@ abstract class AbstractUpdateRecord /** - * @param Model|null $model - * @return Model|null + * @param Model $model + * @return Model * @throws MalformedRequestException */ - public function handler(?Model $model){ + public function handler(Model $model){ try{ + if($model->save()){ return $model; } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php index 3b14f6c2..a28df296 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/AuthenticateUserLogic.php @@ -53,13 +53,12 @@ class AuthenticateUserLogic extends AbstractControllerLogic $object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password'), $request->input('remember_me')); - if($this->canAuthenticateUser->passes($object)){ + $this->canAuthenticateUser->passes($object); - $token = $this->authenticatesUser->execute($object); + $token = $this->authenticatesUser->execute($object); - return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); + return $this->response(['access_token' => $token, 'redirect_url' => $this->authenticationRedirect->url()]); - } } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php new file mode 100644 index 00000000..d988fe08 --- /dev/null +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateUserLogic.php @@ -0,0 +1,129 @@ +generatesUniqueAccountNumber = $generatesUniqueAccountNumber; + $this->canCreateUser = $canCreateUser; + $this->createsUser = $createsUser; + $this->createCompanyProcessor = $createCompanyProcessor; + $this->createsCompanyModule = $createsCompanyModule; + $this->createsCompanyEmployee = $createsCompanyEmployee; + $this->createsCompanyConnection = $createsCompanyConnection; + $this->createContactProcessor = $createContactProcessor; + $this->authenticateUserLogic = $authenticateUserLogic; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request): JsonResponse { + + try { + + $registrationObject = new RegistrationObject($request->input('email'), $request->input('name'), + $request->input('password'), $request->input('confirm_password')); + + $this->canCreateUser->passes($registrationObject); + + /** @var User $user */ + $user = $this->createsUser->execute($registrationObject); + + $request->request->set('name', $request->input('company_name')); + + /** @var Company $company */ + $company = $this->createCompanyProcessor->execute($request); + + $request->request->add(['company_id' => $company->id, 'name' => $registrationObject->getName()]); + $this->createContactProcessor->execute($request); + + /** @var CompanyModule $module */ + $module = $this->createsCompanyModule->execute(new ModuleObject($company, ModuleTypes::IMPORTER)); + + $this->createsCompanyEmployee->execute(new EmployeeObject($module, $user, CompanyRoles::OWNER)); + + $this->createsCompanyConnection->execute(new ConnectionObject($module, CompanyModule::find(1))); + + return $this->authenticateUserLogic->execute($request); + + } 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/ControllersLogic/ListUsersControllerLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/ListUsersLogic.php similarity index 96% rename from app/Classes/Modules/Accounts/ControllersLogic/ListUsersControllerLogic.php rename to app/Classes/Modules/Accounts/ControllersLogic/ListUsersLogic.php index d2e8415a..706a6053 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/ListUsersControllerLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/ListUsersLogic.php @@ -9,7 +9,7 @@ use App\Http\Resources\UserResource; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -class ListUsersControllerLogic extends AbstractControllerLogic +class ListUsersLogic extends AbstractControllerLogic { /** diff --git a/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php b/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php new file mode 100644 index 00000000..d01a44d4 --- /dev/null +++ b/app/Classes/Modules/Accounts/DataTransferObjects/RegistrationObject.php @@ -0,0 +1,71 @@ +email = $email; + $this->name = $name; + $this->password = $password; + $this->confirmPassword = $confirmPassword; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return string + */ + public function getPassword(): string + { + return $this->password; + } + + /** + * @return string + */ + public function getConfirmPassword(): string + { + return $this->confirmPassword; + } + + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Services/CreatesUser.php b/app/Classes/Modules/Accounts/Services/CreatesUser.php new file mode 100644 index 00000000..170e2c76 --- /dev/null +++ b/app/Classes/Modules/Accounts/Services/CreatesUser.php @@ -0,0 +1,30 @@ +email = $object->getEmail(); + $model->name = $object->getName(); + $model->password = Hash::make($object->getPassword()); + $model->role_id = Roles::USER; + + return $this->handler($model); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Rules/CanCreateUser.php b/app/Classes/Modules/Accounts/Standards/Rules/CanCreateUser.php new file mode 100644 index 00000000..27e1e358 --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Rules/CanCreateUser.php @@ -0,0 +1,58 @@ +userRegistrationValidation = $userRegistrationValidation; + } + + + /** + * @return bool + */ + protected function authorized(): bool + { + return true; + + } + + /** + * @param AuthenticationCredentialsObject $object + * @return bool + * @throws RequestValidationException + */ + protected function validators($object): bool + { + return $this->userRegistrationValidation->validate($object); + + } + + + /** + * @param AuthenticationCredentialsObject $object + * @return bool + */ + protected function criteria($object): bool + { + return true; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php b/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php new file mode 100644 index 00000000..25f2335d --- /dev/null +++ b/app/Classes/Modules/Accounts/Standards/Validators/UserRegistrationValidation.php @@ -0,0 +1,48 @@ + $object->getEmail(), + 'name' => $object->getName(), + 'password' => $object->getPassword(), + 'confirm_password' => $object->getConfirmPassword(), + ]; + } + + /** + * @return array + */ + protected function rules(): array { + return [ + 'email' => 'required|email|unique:users', + 'name' => 'required', + 'password' => 'required', + 'confirm_password' => 'required|same:password', + + ]; + } + + /** + * @return array + */ + protected function messages(): array { + return []; + } + + + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Addresses/ControllerLogic/CreateAddressControllerLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/CreateAddressLogic.php similarity index 94% rename from app/Classes/Modules/Addresses/ControllerLogic/CreateAddressControllerLogic.php rename to app/Classes/Modules/Addresses/ControllersLogic/CreateAddressLogic.php index c66c9dce..7badc419 100644 --- a/app/Classes/Modules/Addresses/ControllerLogic/CreateAddressControllerLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/CreateAddressLogic.php @@ -1,6 +1,6 @@ company_id = $object->getCompanyId(); diff --git a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php index 523b3000..76ba4d15 100644 --- a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php +++ b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php @@ -9,6 +9,12 @@ use App\Models\Address; class UpdatesAddress extends AbstractUpdateRecord { + /** + * @param Address $model + * @param AddressObject $object + * @return \Illuminate\Database\Eloquent\Model + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(Address $model, AddressObject $object) { $model->company_id = $object->getCompanyId(); diff --git a/app/Classes/Modules/Companies/ControllerLogic/CreateCompanyControllerLogic.php b/app/Classes/Modules/Companies/ControllerLogic/CreateCompanyControllerLogic.php deleted file mode 100644 index ff0902cd..00000000 --- a/app/Classes/Modules/Companies/ControllerLogic/CreateCompanyControllerLogic.php +++ /dev/null @@ -1,69 +0,0 @@ - 'Created Company', - 'message' => 'You have successfully created a new Company' - ]; - } - - /** @var CanCreateCompany */ - private $canCreateCompany; - - /** @var CreatesCompany */ - private $createsCompany; - - /** - * CreateCompanyControllerLogic constructor. - * @param CanCreateCompany $canCreateCompany - * @param CreatesCompany $createsCompany - */ - public function __construct(CanCreateCompany $canCreateCompany, CreatesCompany $createsCompany) - { - $this->canCreateCompany = $canCreateCompany; - $this->createsCompany = $createsCompany; - } - - - /** - * @param Request $request - * @return JsonResponse - * @throws ErrorException - */ - public function logic(Request $request) : JsonResponse - { - try { - - $object = new CompanyObject($request->input('reference_no'), $request->input('name'), $request->input('type')); - - $this->canCreateCompany->passes($object); - - $query = $this->createsCompany->execute($object); - - return $this->resourceResponse(new CompanyResource($query)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } - - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/CreateCompanyLogic.php b/app/Classes/Modules/Companies/ControllersLogic/CreateCompanyLogic.php new file mode 100644 index 00000000..7f9c25a3 --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/CreateCompanyLogic.php @@ -0,0 +1,55 @@ + 'Created Company', + 'message' => 'You have successfully created a new Company' + ]; + } + + /** @var CreateCompanyProcessor */ + private $createCompanyProcessor; + + /** + * CreateCompanyLogic constructor. + * @param CreateCompanyProcessor $createCompanyProcessor + */ + public function __construct(CreateCompanyProcessor $createCompanyProcessor) + { + $this->createCompanyProcessor = $createCompanyProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + + return $this->resourceResponse(new CompanyResource($this->createCompanyProcessor->execute($request))); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllerLogic/DeleteCompanyControllerLogic.php b/app/Classes/Modules/Companies/ControllersLogic/DeleteCompanyLogic.php similarity index 91% rename from app/Classes/Modules/Companies/ControllerLogic/DeleteCompanyControllerLogic.php rename to app/Classes/Modules/Companies/ControllersLogic/DeleteCompanyLogic.php index afa5a332..83d3548b 100644 --- a/app/Classes/Modules/Companies/ControllerLogic/DeleteCompanyControllerLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/DeleteCompanyLogic.php @@ -1,6 +1,6 @@ referenceNo = $referenceNo; $this->name = $name; @@ -30,9 +30,9 @@ class CompanyObject implements DataTransferObject } /** - * @return integer + * @return int */ - public function getReferenceNo(): integer + public function getReferenceNo(): int { return $this->referenceNo; } @@ -46,13 +46,12 @@ class CompanyObject implements DataTransferObject } /** - * @return integer + * @return int */ - public function getType(): integer + public function getType(): int { return $this->type; } - } \ No newline at end of file diff --git a/app/Classes/Modules/Companies/DataTransferObjects/ConnectionObject.php b/app/Classes/Modules/Companies/DataTransferObjects/ConnectionObject.php new file mode 100644 index 00000000..078378b4 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/ConnectionObject.php @@ -0,0 +1,45 @@ +inviter = $inviter; + $this->invitee = $invitee; + } + + /** + * @return CompanyModule + */ + public function getInviter(): CompanyModule + { + return $this->inviter; + } + + /** + * @return CompanyModule + */ + public function getInvitee(): CompanyModule + { + return $this->invitee; + } + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/DataTransferObjects/EmployeeObject.php b/app/Classes/Modules/Companies/DataTransferObjects/EmployeeObject.php new file mode 100644 index 00000000..816a2de5 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/EmployeeObject.php @@ -0,0 +1,58 @@ +companyModule = $companyModule; + $this->user = $user; + $this->role = $role; + } + + /** + * @return CompanyModule + */ + public function getCompanyModule(): CompanyModule + { + return $this->companyModule; + } + + /** + * @return User + */ + public function getUser(): User + { + return $this->user; + } + + /** + * @return int + */ + public function getRole(): int + { + return $this->role; + } + + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/DataTransferObjects/ModuleObject.php b/app/Classes/Modules/Companies/DataTransferObjects/ModuleObject.php new file mode 100644 index 00000000..732799a3 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/ModuleObject.php @@ -0,0 +1,44 @@ +company = $company; + $this->type = $type; + } + + /** + * @return Company + */ + public function getCompany(): Company + { + return $this->company; + } + + /** + * @return int + */ + public function getType(): int + { + return $this->type; + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Processors/CreateCompanyProcessor.php b/app/Classes/Modules/Companies/Processors/CreateCompanyProcessor.php new file mode 100644 index 00000000..99f35bb0 --- /dev/null +++ b/app/Classes/Modules/Companies/Processors/CreateCompanyProcessor.php @@ -0,0 +1,53 @@ +canCreateCompany = $canCreateCompany; + $this->createsCompany = $createsCompany; + $this->generatesUniqueAccountNumber = $generatesUniqueAccountNumber; + } + + /** + * @param Request $request + * @return \Illuminate\Database\Eloquent\Model|null + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function execute(Request $request){ + + $object = new CompanyObject($this->generatesUniqueAccountNumber->execute(), $request->input('name'), $request->input('type')); + + $this->canCreateCompany->passes($object); + + return $this->createsCompany->execute($object); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/ChecksIfCompanyAccountNumberExists.php b/app/Classes/Modules/Companies/Services/ChecksIfCompanyAccountNumberExists.php new file mode 100644 index 00000000..d2551ab2 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/ChecksIfCompanyAccountNumberExists.php @@ -0,0 +1,26 @@ +repository = $repository; + } + + public function execute(int $accountNumber): bool { + return $this->repository->where('reference_no', $accountNumber)->exists(); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/CreatesCompany.php b/app/Classes/Modules/Companies/Services/CreatesCompany.php index 0cd92ed1..3cddba30 100644 --- a/app/Classes/Modules/Companies/Services/CreatesCompany.php +++ b/app/Classes/Modules/Companies/Services/CreatesCompany.php @@ -9,6 +9,11 @@ use App\Models\Company; class CreatesCompany extends AbstractUpdateRecord { + /** + * @param CompanyObject $object + * @return \Illuminate\Database\Eloquent\Model|null + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(CompanyObject $object) { $model = new Company(); $model->reference_no = $object->getReferenceNo(); diff --git a/app/Classes/Modules/Companies/Services/CreatesCompanyConnection.php b/app/Classes/Modules/Companies/Services/CreatesCompanyConnection.php new file mode 100644 index 00000000..cab27888 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/CreatesCompanyConnection.php @@ -0,0 +1,20 @@ +getInviter()->connections()->attach($connection->getInvitee(), + [ + 'status' => ConnectionStatus::APPROVED, + 'instigator' => $connection->getInvitee()->id + ] + ); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/CreatesCompanyEmployee.php b/app/Classes/Modules/Companies/Services/CreatesCompanyEmployee.php new file mode 100644 index 00000000..b8419f9a --- /dev/null +++ b/app/Classes/Modules/Companies/Services/CreatesCompanyEmployee.php @@ -0,0 +1,19 @@ +getCompanyModule()->employees()->attach($employee->getUser(), [ + 'role_id' => $employee->getRole(), + 'active' => true + ]); + + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/CreatesCompanyModule.php b/app/Classes/Modules/Companies/Services/CreatesCompanyModule.php new file mode 100644 index 00000000..87c5ef84 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/CreatesCompanyModule.php @@ -0,0 +1,24 @@ +getCompany()->modules()->create(['module_type' => $module->getType()]); + + return $this->handler($model); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/DeletesCompany.php b/app/Classes/Modules/Companies/Services/DeletesCompany.php index 3818a893..046c8b5f 100644 --- a/app/Classes/Modules/Companies/Services/DeletesCompany.php +++ b/app/Classes/Modules/Companies/Services/DeletesCompany.php @@ -9,6 +9,11 @@ use App\Models\Company; class DeletesCompany extends AbstractDeleteRecord { + /** + * @param Company $model + * @return mixed + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(Company $model) { return $this->handler($model); } diff --git a/app/Classes/Modules/Companies/Services/GeneratesUniqueAccountNumber.php b/app/Classes/Modules/Companies/Services/GeneratesUniqueAccountNumber.php new file mode 100644 index 00000000..48a92e20 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/GeneratesUniqueAccountNumber.php @@ -0,0 +1,31 @@ +accountNumberExists = $accountNumberExists; + } + + /** + * @return int + */ + public function execute(): int { + + $number = mt_rand(100000001, 999999999); + return !$this->accountNumberExists->execute($number) ? $number : self::execute(); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompany.php b/app/Classes/Modules/Companies/Services/UpdatesCompany.php index 0ffb47be..510d3c0c 100644 --- a/app/Classes/Modules/Companies/Services/UpdatesCompany.php +++ b/app/Classes/Modules/Companies/Services/UpdatesCompany.php @@ -9,6 +9,12 @@ use App\Models\Company; class UpdatesCompany extends AbstractUpdateRecord { + /** + * @param Company $model + * @param CompanyObject $object + * @return \Illuminate\Database\Eloquent\Model|null + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(Company $model, CompanyObject $object) { $model->reference_no = $object->getReferenceNo(); diff --git a/app/Classes/Modules/Contacts/ControllerLogic/CreateContactControllerLogic.php b/app/Classes/Modules/Contacts/ControllerLogic/CreateContactControllerLogic.php deleted file mode 100644 index bbd17f5e..00000000 --- a/app/Classes/Modules/Contacts/ControllerLogic/CreateContactControllerLogic.php +++ /dev/null @@ -1,70 +0,0 @@ - 'Created Contact', - 'message' => 'You have successfully created a new Contact' - ]; - } - - /** @var CanCreateContact */ - private $canCreateContact; - - /** @var CreatesContact */ - private $createsContact; - - /** - * CreateContactControllerLogic constructor. - * @param CanCreateContact $canCreateContact - * @param CreatesContact $createsContact - */ - public function __construct(CanCreateContact $canCreateContact, CreatesContact $createsContact) - { - $this->canCreateContact = $canCreateContact; - $this->createsContact = $createsContact; - } - - - /** - * @param Request $request - * @return JsonResponse - * @throws ErrorException - */ - public function logic(Request $request) : JsonResponse - { - dd($request->all()); - try { - - $object = new ContactObject($request->input('company_id'), $request->input('name'), $request->input('designation'), $request->input('email'), $request->input('phone'), $request->input('wechat_id')); - - $this->canCreateContact->passes($object); - - $query = $this->createsContact->execute($object); - - return $this->resourceResponse(new ContactResource($query)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } - - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Contacts/ControllersLogic/CreateContactLogic.php b/app/Classes/Modules/Contacts/ControllersLogic/CreateContactLogic.php new file mode 100644 index 00000000..4ed66db8 --- /dev/null +++ b/app/Classes/Modules/Contacts/ControllersLogic/CreateContactLogic.php @@ -0,0 +1,55 @@ + 'Created Contact', + 'message' => 'You have successfully created a new Contact' + ]; + } + + /** @var CreateContactProcessor */ + private $createContactProcessor; + + /** + * CreateContactLogic constructor. + * @param CreateContactProcessor $createContactProcessor + */ + public function __construct(CreateContactProcessor $createContactProcessor) + { + $this->createContactProcessor = $createContactProcessor; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws ErrorException + */ + public function logic(Request $request) : JsonResponse + { + try { + + return $this->resourceResponse(new ContactResource($this->createContactProcessor->execute($request))); + + } catch (\Exception $exception){ + throw new ErrorException($exception->getMessage(), $exception->getCode()); + } + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Contacts/ControllerLogic/DeleteContactControllerLogic.php b/app/Classes/Modules/Contacts/ControllersLogic/DeleteContactLogic.php similarity index 93% rename from app/Classes/Modules/Contacts/ControllerLogic/DeleteContactControllerLogic.php rename to app/Classes/Modules/Contacts/ControllersLogic/DeleteContactLogic.php index fb3f6aa5..442fd201 100644 --- a/app/Classes/Modules/Contacts/ControllerLogic/DeleteContactControllerLogic.php +++ b/app/Classes/Modules/Contacts/ControllersLogic/DeleteContactLogic.php @@ -1,6 +1,6 @@ canCreateContact = $canCreateContact; + $this->createsContact = $createsContact; + } + + /** + * @param Request $request + * @return \Illuminate\Database\Eloquent\Model + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function execute(Request $request){ + $object = new ContactObject($request->input('company_id'), $request->input('name'), $request->input('designation'), $request->input('email'), $request->input('phone'), $request->input('wechat_id')); + + $this->canCreateContact->passes($object); + + return $this->createsContact->execute($object); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Contacts/Services/CreatesContact.php b/app/Classes/Modules/Contacts/Services/CreatesContact.php index f895685d..aea20372 100644 --- a/app/Classes/Modules/Contacts/Services/CreatesContact.php +++ b/app/Classes/Modules/Contacts/Services/CreatesContact.php @@ -9,6 +9,11 @@ use App\Models\Contact; class CreatesContact extends AbstractUpdateRecord { + /** + * @param ContactObject $object + * @return \Illuminate\Database\Eloquent\Model + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(ContactObject $object) { $model = new Contact(); $model->company_id = $object->getCompanyId(); diff --git a/app/Classes/Modules/Contacts/Services/UpdatesContact.php b/app/Classes/Modules/Contacts/Services/UpdatesContact.php index 3c17a6f8..68b13672 100644 --- a/app/Classes/Modules/Contacts/Services/UpdatesContact.php +++ b/app/Classes/Modules/Contacts/Services/UpdatesContact.php @@ -9,6 +9,12 @@ use App\Models\Contact; class UpdatesContact extends AbstractUpdateRecord { + /** + * @param Contact $model + * @param ContactObject $object + * @return \Illuminate\Database\Eloquent\Model + * @throws \App\Classes\Exceptions\MalformedRequestException + */ public function execute(Contact $model, ContactObject $object) { $model->company_id = $object->getCompanyId(); diff --git a/app/Classes/ValueObjects/Constants/CompanyRoles.php b/app/Classes/ValueObjects/Constants/CompanyRoles.php new file mode 100644 index 00000000..342bd05e --- /dev/null +++ b/app/Classes/ValueObjects/Constants/CompanyRoles.php @@ -0,0 +1,11 @@ + self::CLIENT_MODULE, - 'project' => self::PROJECT_MODULE, - 'task' => self::TASK_MODULE, - 'ticket' => self::TICKET_MODULE, - 'document' => self::DOCUMENT_MODULE, - 'field' => self::FIELD_MODULE, - 'status' => self::STATUS_LIST, - ]; - - public const STATUS_LIST= 21; - -} diff --git a/app/Classes/ValueObjects/Constants/ModuleTypes.php b/app/Classes/ValueObjects/Constants/ModuleTypes.php new file mode 100644 index 00000000..0baaa53b --- /dev/null +++ b/app/Classes/ValueObjects/Constants/ModuleTypes.php @@ -0,0 +1,13 @@ + 'You have successfully logged in to your account' ]; + public const REGISTRATION = [ + 'title' => 'Registration', + 'message' => 'You have successfully created a new account' + ]; + public const RESET_PASSWORD = [ 'title' => 'Reset Password', 'message' => 'You have successfully sent you an email to reset your password' diff --git a/app/Classes/ValueObjects/Constants/RelationStatus.php b/app/Classes/ValueObjects/Constants/RelationStatus.php new file mode 100644 index 00000000..af938752 --- /dev/null +++ b/app/Classes/ValueObjects/Constants/RelationStatus.php @@ -0,0 +1,17 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Account/Authentication/GeneratePasswordResetController.php b/app/Http/Controllers/Account/GeneratePasswordResetController.php similarity index 89% rename from app/Http/Controllers/Account/Authentication/GeneratePasswordResetController.php rename to app/Http/Controllers/Account/GeneratePasswordResetController.php index 079adba4..a980a08e 100644 --- a/app/Http/Controllers/Account/Authentication/GeneratePasswordResetController.php +++ b/app/Http/Controllers/Account/GeneratePasswordResetController.php @@ -1,6 +1,6 @@ execute($request); } diff --git a/app/Http/Controllers/Account/Authentication/ResetPasswordController.php b/app/Http/Controllers/Account/ResetPasswordController.php similarity index 88% rename from app/Http/Controllers/Account/Authentication/ResetPasswordController.php rename to app/Http/Controllers/Account/ResetPasswordController.php index fb12c863..284d2077 100644 --- a/app/Http/Controllers/Account/Authentication/ResetPasswordController.php +++ b/app/Http/Controllers/Account/ResetPasswordController.php @@ -1,6 +1,6 @@ execute($request); } diff --git a/app/Http/Controllers/Addresses/DeleteAddressController.php b/app/Http/Controllers/Addresses/DeleteAddressController.php index 380a8c41..dc0fc6b1 100644 --- a/app/Http/Controllers/Addresses/DeleteAddressController.php +++ b/app/Http/Controllers/Addresses/DeleteAddressController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Addresses; -use App\Classes\Modules\Addresses\ControllerLogic\DeleteAddressControllerLogic; +use App\Classes\Modules\Addresses\ControllersLogic\DeleteAddressLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class DeleteAddressController { /** * @param Request $request - * @param DeleteAddressControllerLogic $logic + * @param DeleteAddressLogic $logic * @return JsonResponse */ - public function destroy(Request $request, DeleteAddressControllerLogic $logic): JsonResponse { + public function destroy(Request $request, DeleteAddressLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Addresses/FetchAddressController.php b/app/Http/Controllers/Addresses/FetchAddressController.php index a348a9a1..3691100d 100644 --- a/app/Http/Controllers/Addresses/FetchAddressController.php +++ b/app/Http/Controllers/Addresses/FetchAddressController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Addresses; -use App\Classes\Modules\Addresses\ControllerLogic\FetchAddressControllerLogic; +use App\Classes\Modules\Addresses\ControllersLogic\FetchAddressLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class FetchAddressController { /** * @param Request $request - * @param FetchAddressControllerLogic $logic + * @param FetchAddressLogic $logic * @return JsonResponse */ - public function fetch(Request $request, FetchAddressControllerLogic $logic): JsonResponse { + public function fetch(Request $request, FetchAddressLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Addresses/ListAddressesController.php b/app/Http/Controllers/Addresses/ListAddressesController.php index c6e03d5c..75ae20a4 100644 --- a/app/Http/Controllers/Addresses/ListAddressesController.php +++ b/app/Http/Controllers/Addresses/ListAddressesController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Addresses; -use App\Classes\Modules\Addresses\ControllerLogic\ListAddressesControllerLogic; +use App\Classes\Modules\Addresses\ControllersLogic\ListAddressesLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class ListAddressesController { /** * @param Request $request - * @param listAddressesControllerLogic $logic + * @param ListAddressesLogic $logic * @return JsonResponse */ - public function list(Request $request, listAddressesControllerLogic $logic): JsonResponse { + public function list(Request $request, ListAddressesLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Addresses/UpdateAddressController.php b/app/Http/Controllers/Addresses/UpdateAddressController.php index 1fd3f356..78ca4136 100644 --- a/app/Http/Controllers/Addresses/UpdateAddressController.php +++ b/app/Http/Controllers/Addresses/UpdateAddressController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Addresses; -use App\Classes\Modules\Addresses\ControllerLogic\UpdateAddressControllerLogic; +use App\Classes\Modules\Addresses\ControllersLogic\UpdateAddressLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class UpdateAddressController { /** * @param Request $request - * @param UpdateAddressControllerLogic $logic + * @param UpdateAddressLogic $logic * @return JsonResponse */ - public function update(Request $request, UpdateAddressControllerLogic $logic): JsonResponse { + public function update(Request $request, UpdateAddressLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Companies/CreateCompanyController.php b/app/Http/Controllers/Companies/CreateCompanyController.php index 67a7e30f..2ed56acc 100644 --- a/app/Http/Controllers/Companies/CreateCompanyController.php +++ b/app/Http/Controllers/Companies/CreateCompanyController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Companies; -use App\Classes\Modules\Companies\ControllerLogic\CreateCompanyControllerLogic; +use App\Classes\Modules\Companies\ControllersLogic\CreateCompanyLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class CreateCompanyController { /** * @param Request $request - * @param CreateCompanyControllerLogic $logic + * @param CreateCompanyLogic $logic * @return JsonResponse */ - public function create(Request $request, CreateCompanyControllerLogic $logic): JsonResponse { + public function create(Request $request, CreateCompanyLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Companies/DeleteCompanyController.php b/app/Http/Controllers/Companies/DeleteCompanyController.php index 0eae86b5..f59a8eaa 100644 --- a/app/Http/Controllers/Companies/DeleteCompanyController.php +++ b/app/Http/Controllers/Companies/DeleteCompanyController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Companies; -use App\Classes\Modules\Companies\ControllerLogic\DeleteCompanyControllerLogic; +use App\Classes\Modules\Companies\ControllersLogic\DeleteCompanyLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class DeleteCompanyController { /** * @param Request $request - * @param DeleteCompanyControllerLogic $logic + * @param DeleteCompanyLogic $logic * @return JsonResponse */ - public function destroy(Request $request, DeleteCompanyControllerLogic $logic): JsonResponse { + public function destroy(Request $request, DeleteCompanyLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Companies/FetchCompanyController.php b/app/Http/Controllers/Companies/FetchCompanyController.php index 4e02d14a..cc4a9a02 100644 --- a/app/Http/Controllers/Companies/FetchCompanyController.php +++ b/app/Http/Controllers/Companies/FetchCompanyController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Companies; -use App\Classes\Modules\Companies\ControllerLogic\FetchCompanyControllerLogic; +use App\Classes\Modules\Companies\ControllersLogic\FetchCompanyLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class FetchCompanyController { /** * @param Request $request - * @param FetchCompanyControllerLogic $logic + * @param FetchCompanyLogic $logic * @return JsonResponse */ - public function fetch(Request $request, FetchCompanyControllerLogic $logic): JsonResponse { + public function fetch(Request $request, FetchCompanyLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Companies/ListCompaniesController.php b/app/Http/Controllers/Companies/ListCompaniesController.php index 9bd2f2b0..25b8ae76 100644 --- a/app/Http/Controllers/Companies/ListCompaniesController.php +++ b/app/Http/Controllers/Companies/ListCompaniesController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Companies; -use App\Classes\Modules\Companies\ControllerLogic\ListCompaniesControllerLogic; +use App\Classes\Modules\Companies\ControllersLogic\ListCompaniesLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class ListCompaniesController { /** * @param Request $request - * @param listCompaniesControllerLogic $logic + * @param ListCompaniesLogic $logic * @return JsonResponse */ - public function list(Request $request, listCompaniesControllerLogic $logic): JsonResponse { + public function list(Request $request, ListCompaniesLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Companies/UpdateCompanyController.php b/app/Http/Controllers/Companies/UpdateCompanyController.php index 33ad8338..3ff239fb 100644 --- a/app/Http/Controllers/Companies/UpdateCompanyController.php +++ b/app/Http/Controllers/Companies/UpdateCompanyController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Companies; -use App\Classes\Modules\Companies\ControllerLogic\UpdateCompanyControllerLogic; +use App\Classes\Modules\Companies\ControllersLogic\UpdateCompanyLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class UpdateCompanyController { /** * @param Request $request - * @param UpdateCompanyControllerLogic $logic + * @param UpdateCompanyLogic $logic * @return JsonResponse */ - public function update(Request $request, UpdateCompanyControllerLogic $logic): JsonResponse { + public function update(Request $request, UpdateCompanyLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Contacts/CreateContactController.php b/app/Http/Controllers/Contacts/CreateContactController.php index 3dd089aa..0c3eff05 100644 --- a/app/Http/Controllers/Contacts/CreateContactController.php +++ b/app/Http/Controllers/Contacts/CreateContactController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Contacts; -use App\Classes\Modules\Contacts\ControllerLogic\CreateContactControllerLogic; +use App\Classes\Modules\Contacts\ControllersLogic\CreateContactLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class CreateContactController { /** * @param Request $request - * @param CreateContactControllerLogic $logic + * @param CreateContactLogic $logic * @return JsonResponse */ - public function create(Request $request, CreateContactControllerLogic $logic): JsonResponse { + public function create(Request $request, CreateContactLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Contacts/DeleteContactController.php b/app/Http/Controllers/Contacts/DeleteContactController.php index 3ca4c209..d58e26b5 100644 --- a/app/Http/Controllers/Contacts/DeleteContactController.php +++ b/app/Http/Controllers/Contacts/DeleteContactController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Contacts; -use App\Classes\Modules\Contacts\ControllerLogic\DeleteContactControllerLogic; +use App\Classes\Modules\Contacts\ControllersLogic\DeleteContactLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class DeleteContactController { /** * @param Request $request - * @param DeleteContactControllerLogic $logic + * @param DeleteContactLogic $logic * @return JsonResponse */ - public function destroy(Request $request, DeleteContactControllerLogic $logic): JsonResponse { + public function destroy(Request $request, DeleteContactLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Contacts/FetchContactController.php b/app/Http/Controllers/Contacts/FetchContactController.php index 7fd48a27..57d16cb7 100644 --- a/app/Http/Controllers/Contacts/FetchContactController.php +++ b/app/Http/Controllers/Contacts/FetchContactController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Contacts; -use App\Classes\Modules\Contacts\ControllerLogic\FetchContactControllerLogic; +use App\Classes\Modules\Contacts\ControllersLogic\FetchContactLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class FetchContactController { /** * @param Request $request - * @param FetchContactControllerLogic $logic + * @param FetchContactLogic $logic * @return JsonResponse */ - public function fetch(Request $request, FetchContactControllerLogic $logic): JsonResponse { + public function fetch(Request $request, FetchContactLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Contacts/ListContactsController.php b/app/Http/Controllers/Contacts/ListContactsController.php index 179bd117..bdc3aeba 100644 --- a/app/Http/Controllers/Contacts/ListContactsController.php +++ b/app/Http/Controllers/Contacts/ListContactsController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Contacts; -use App\Classes\Modules\Contacts\ControllerLogic\ListContactsControllerLogic; +use App\Classes\Modules\Contacts\ControllersLogic\ListContactsLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class ListContactsController { /** * @param Request $request - * @param listContactsControllerLogic $logic + * @param ListContactsLogic $logic * @return JsonResponse */ - public function list(Request $request, listContactsControllerLogic $logic): JsonResponse { + public function list(Request $request, ListContactsLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Http/Controllers/Contacts/UpdateContactController.php b/app/Http/Controllers/Contacts/UpdateContactController.php index 4f36d823..d96a1135 100644 --- a/app/Http/Controllers/Contacts/UpdateContactController.php +++ b/app/Http/Controllers/Contacts/UpdateContactController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers\Contacts; -use App\Classes\Modules\Contacts\ControllerLogic\UpdateContactControllerLogic; +use App\Classes\Modules\Contacts\ControllersLogic\UpdateContactLogic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -10,10 +10,10 @@ class UpdateContactController { /** * @param Request $request - * @param UpdateContactControllerLogic $logic + * @param UpdateContactLogic $logic * @return JsonResponse */ - public function update(Request $request, UpdateContactControllerLogic $logic): JsonResponse { + public function update(Request $request, UpdateContactLogic $logic): JsonResponse { return $logic->execute($request); } diff --git a/app/Models/Address.php b/app/Models/Address.php index e2880dae..2873ae8f 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -2,7 +2,7 @@ namespace App\Models; -use App\Models\AbstractModel as Model; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; @@ -26,60 +26,15 @@ class Address extends AbstractModel protected $table = 'addresses'; - - protected $dates = ['deleted_at']; - - - public $fillable = [ - 'street_one', - 'street_two', - 'city', - 'state', - 'post_code', - 'country' - ]; - - /** - * The attributes that should be casted to native types. - * - * @var array - */ - protected $casts = [ - 'street_one' => 'string', - 'street_two' => 'string', - 'city' => 'string', - 'state' => 'string', - 'post_code' => 'string', - 'country' => 'string', - 'default' => 'integer', - 'billing' => 'integer' - ]; - - /** - * Validation rules - * - * @var array - */ - public static $rules = [ - 'company_id' => 'required', - 'street_one' => 'required', - 'city' => 'required', - 'state' => 'required', - 'post_code' => 'required', - 'country' => 'required', - 'default' => 'required', - 'billing' => 'required' - ]; - /** * @return \Illuminate\Database\Eloquent\Relations\HasOne **/ public function company(): HasOne { - return $this->hasOne(\App\Models\Company::class, 'company_id', 'id'); + return $this->hasOne(Company::class, 'company_id', 'id'); } } diff --git a/app/Models/Company.php b/app/Models/Company.php index 4f37c7bf..5d912650 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -4,6 +4,7 @@ namespace App\Models; use App\Models\AbstractModel as Model; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; @@ -23,49 +24,48 @@ class Company extends AbstractModel protected $table = 'companies'; - - protected $dates = ['deleted_at']; - - - public $fillable = [ - 'name', - 'type' - ]; - /** - * The attributes that should be casted to native types. - * - * @var array + * @return HasMany */ - protected $casts = [ - 'reference_no' => 'integer', - 'name' => 'string', - 'type' => 'integer' - ]; - - /** - * Validation rules - * - * @var array - */ - public static $rules = [ - 'reference_no' => 'required', - 'name' => 'required', - 'type' => 'required' - ]; - public function addresses(): hasMany { return $this->hasMany(Address::class, 'company_id', 'id'); } + /** + * @return HasOne + */ public function deliveryAddress(): hasOne { return $this->hasOne(Address::class)->where('default', 1); } + /** + * @return HasMany + */ + public function modules(): hasMany + { + return $this->hasMany(CompanyModule::class); + } + + /** + * @return hasManyThrough + */ + public function employees(): hasManyThrough + { + return $this->hasManyThrough(User::class, CompanyEmployee::class); + } + + /** + * @return HasManyThrough + */ + public function connections(): hasManyThrough + { + return $this->hasManyThrough(Company::class, CompanyConnections::class); + } + } diff --git a/app/Models/CompanyConnections.php b/app/Models/CompanyConnections.php new file mode 100644 index 00000000..4638ad82 --- /dev/null +++ b/app/Models/CompanyConnections.php @@ -0,0 +1,36 @@ +belongsToMany(CompanyModule::class); + } + + + +} diff --git a/app/Models/CompanyEmployee.php b/app/Models/CompanyEmployee.php new file mode 100644 index 00000000..7b660c51 --- /dev/null +++ b/app/Models/CompanyEmployee.php @@ -0,0 +1,47 @@ +hasOneThrough(Company::class, CompanyModule::class); + } + + public function user(): belongsTo + { + return $this->belongsTo(User::class); + } + + + +} diff --git a/app/Models/CompanyModule.php b/app/Models/CompanyModule.php new file mode 100644 index 00000000..da614e56 --- /dev/null +++ b/app/Models/CompanyModule.php @@ -0,0 +1,60 @@ +belongsTo(Company::class); + } + + /** + * @return belongsToMany + */ + public function employees(): belongsToMany + { + return $this->belongsToMany(User::class, (new CompanyEmployee())->getTable(), 'module_id','user_id'); + } + + /** + * @return BelongsToMany + */ + public function connections(): belongsToMany + { + return $this->belongsToMany(CompanyModule::class, (new CompanyConnections())->getTable(), 'module_one', 'module_two'); + } + +} diff --git a/app/Models/Contact.php b/app/Models/Contact.php index f51a08ed..b05a6e8b 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -2,7 +2,7 @@ namespace App\Models; -use App\Models\AbstractModel as Model; +use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; @@ -30,42 +30,10 @@ class Contact extends AbstractModel protected $dates = ['deleted_at']; - - - public $fillable = [ - 'name', - 'designation', - 'email', - 'phone', - 'wechat_id' - ]; /** - * The attributes that should be casted to native types. - * - * @var array + * @return HasOne */ - protected $casts = [ - 'name' => 'string', - 'designation' => 'string', - 'email' => 'string', - 'phone' => 'string', - 'wechat_id' => 'string' - ]; - - /** - * Validation rules - * - * @var array - */ - public static $rules = [ - 'company_id' => 'required', - 'name' => 'required' - ]; - - /** - * @return \Illuminate\Database\Eloquent\Relations\HasOne - **/ public function company(): HasOne { return $this->hasOne(\App\Models\Company::class, 'company_id', 'id'); diff --git a/app/Models/Order.php b/app/Models/Order.php index 7c07ddfa..c437fcd2 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -2,7 +2,6 @@ namespace App\Models; -use App\Models\AbstractModel as Model; use Illuminate\Database\Eloquent\SoftDeletes; @@ -24,23 +23,8 @@ class Order extends AbstractModel use SoftDeletes; - protected $table = 'orders'; - - protected $dates = ['deleted_at']; - - - public $fillable = [ - 'company_id', - 'marking', - 'forwarder_id', - 'address_id', - 'current_step', - 'multiple_batch', - 'complete' - ]; - } diff --git a/app/Models/PasswordReset.php b/app/Models/PasswordReset.php index c7237869..6ab27179 100644 --- a/app/Models/PasswordReset.php +++ b/app/Models/PasswordReset.php @@ -8,14 +8,17 @@ class PasswordReset extends AbstractModel { protected $table = 'password_resets'; - protected $fillable = [ - 'user_id', 'token', 'is_expired', 'is_complete' - ]; - + /** + * @param $query + * @return mixed + */ public function scopeActive($query){ return $query->where('is_expired', false)->where('is_complete', false); } + /** + * @return BelongsTo + */ public function user(): BelongsTo { return $this->belongsTo(User::class, 'user_id', 'id'); } diff --git a/app/Models/User.php b/app/Models/User.php index 906553c1..ec6b5d71 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -21,32 +21,6 @@ class User extends AbstractModel implements { use Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail; - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = [ - 'name', 'email', 'password', - ]; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = [ - 'password', 'remember_token', - ]; - - /** - * The attributes that should be cast to native types. - * - * @var array - */ - protected $casts = [ - 'email_verified_at' => 'datetime', - ]; /** * Get the identifier that will be stored in the subject claim of the JWT. @@ -68,9 +42,16 @@ class User extends AbstractModel implements return []; } + /** + * @return HasMany + */ public function passwordReset(): HasMany { return $this->hasMany(PasswordReset::class, 'user_id', 'id'); } + public function employers(): hasMany { + return $this->hasMany(CompanyModule::class); + } + } diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index a6874a3e..48160ed8 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -7,8 +7,8 @@ use Faker\Generator as Faker; $factory->define(App\Models\Company::class, function (Faker $faker) { return [ - 'reference_no' => $faker->numerify('##########'), + 'reference_no' => $faker->numerify('#########'), 'name' => $faker->company.' '.$faker->companySuffix, - 'type' => $faker->randomDigitNotNull + 'type' => $faker->randomDigitNotNull, ]; }); diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index ee5d11ac..167a6a78 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,5 +1,6 @@ string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->smallInteger('role_id'); + $table->smallInteger('role_id')->default(Roles::USER); $table->boolean('active')->default(true); $table->rememberToken(); $table->softDeletes(); diff --git a/database/migrations/2020_08_04_023621_create_user_email_verifications_table.php b/database/migrations/2020_08_04_023621_create_user_email_verifications_table.php new file mode 100644 index 00000000..2f4b78e4 --- /dev/null +++ b/database/migrations/2020_08_04_023621_create_user_email_verifications_table.php @@ -0,0 +1,38 @@ +id(); + $table->string('email', 100); + $table->string('token', 32); + $table->boolean('is_complete')->default(false); + $table->boolean('is_active'); + $table->boolean('is_sent')->default(false); + $table->timestamps(); + + $table->foreign('email')->references('email')->on('users'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_email_verifications'); + } +} diff --git a/database/migrations/2020_08_04_042142_create_companies_table.php b/database/migrations/2020_08_04_042142_create_companies_table.php index 567482b8..b9c29ad0 100644 --- a/database/migrations/2020_08_04_042142_create_companies_table.php +++ b/database/migrations/2020_08_04_042142_create_companies_table.php @@ -1,5 +1,6 @@ id(); $table->bigInteger('reference_no')->unique(); $table->string('name'); - $table->integer('type'); - $table->integer('status')->default(0); + $table->integer('type')->comment('business type eg. personal, company'); + $table->integer('status')->default(AccountStatus::PENDING_VERIFICATION); $table->timestamps(); $table->softDeletes(); }); diff --git a/database/migrations/2020_08_04_042264_create_company_modules_table.php b/database/migrations/2020_08_04_042264_create_company_modules_table.php new file mode 100644 index 00000000..b324f42f --- /dev/null +++ b/database/migrations/2020_08_04_042264_create_company_modules_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('company_id'); + $table->integer('module_type')->default(ModuleTypes::IMPORTER); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('company_id')->references('id')->on('companies'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('company_modules'); + } +} diff --git a/database/migrations/2020_08_04_042683_create_company_connections_table.php b/database/migrations/2020_08_04_042683_create_company_connections_table.php new file mode 100644 index 00000000..6c9e3382 --- /dev/null +++ b/database/migrations/2020_08_04_042683_create_company_connections_table.php @@ -0,0 +1,45 @@ +id(); + $table->foreignId('module_one'); + $table->foreignId('module_two'); + $table->integer('status')->default(RelationStatus::PENDING); + $table->foreignId('instigator')->comment('entity that is responsible for current status'); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('module_one')->references('id')->on('company_modules'); + $table->foreign('module_two')->references('id')->on('company_modules'); + + $table->foreign('instigator')->references('id')->on('company_modules'); + + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('company_connections'); + } +} diff --git a/database/migrations/2020_08_04_043286_create_company_employees_table.php b/database/migrations/2020_08_04_043286_create_company_employees_table.php new file mode 100644 index 00000000..9100b727 --- /dev/null +++ b/database/migrations/2020_08_04_043286_create_company_employees_table.php @@ -0,0 +1,42 @@ +id(); + $table->foreignId('module_id'); + $table->foreignId('user_id'); + $table->integer('role_id'); + $table->boolean('active'); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('user_id')->references('id')->on('users'); + $table->foreign('module_id')->references('id')->on('company_modules'); + + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('company_employees'); + } +} diff --git a/database/migrations/2020_08_05_223808_create_order_table.php b/database/migrations/2020_08_05_223808_create_order_table.php deleted file mode 100644 index b724079d..00000000 --- a/database/migrations/2020_08_05_223808_create_order_table.php +++ /dev/null @@ -1,43 +0,0 @@ -id(); - $table->foreignId('company_id'); - $table->string('marking')->unique(); - $table->foreignId('forwarder_id'); - $table->foreignId('address_id'); - $table->string('current_step')->nullable(); - $table->boolean('multiple_batch')->default(0); - $table->boolean('complete')->default(0); - $table->softDeletes(); - $table->timestamps(); - - $table->foreign('company_id')->references('id')->on('companies'); - $table->foreign('forwarder_id')->references('id')->on('companies'); - $table->foreign('address_id')->references('id')->on('addresses'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('order'); - } -} diff --git a/database/migrations/2020_08_06_035532_create_orders_table.php b/database/migrations/2020_08_06_035532_create_orders_table.php index 52eace3c..73064062 100644 --- a/database/migrations/2020_08_06_035532_create_orders_table.php +++ b/database/migrations/2020_08_06_035532_create_orders_table.php @@ -16,18 +16,20 @@ class CreateOrdersTable extends Migration Schema::create('orders', function (Blueprint $table) { $table->id(); $table->foreignId('company_id'); - $table->string('marking')->unique(); + $table->string('order_number')->unique(); $table->foreignId('forwarder_id'); $table->foreignId('address_id'); + $table->foreignId('contact_id'); $table->string('current_step')->nullable(); - $table->boolean('multiple_batch')->default(0); - $table->boolean('complete')->default(0); + $table->boolean('multiple_batch')->default(false); + $table->boolean('complete')->default(false); $table->softDeletes(); $table->timestamps(); $table->foreign('company_id')->references('id')->on('companies'); $table->foreign('forwarder_id')->references('id')->on('companies'); $table->foreign('address_id')->references('id')->on('addresses'); + $table->foreign('contact_id')->references('id')->on('contacts'); }); } diff --git a/database/seeds/AddressesTableSeeder.php b/database/seeds/AddressesTableSeeder.php index e704ec95..2cefe328 100644 --- a/database/seeds/AddressesTableSeeder.php +++ b/database/seeds/AddressesTableSeeder.php @@ -11,6 +11,8 @@ class AddressesTableSeeder extends Seeder */ public function run() { - factory(App\Models\Address::class, 30)->create(); + if (app()->environment('local')) + factory(App\Models\Address::class, 30)->create(); + } } diff --git a/database/seeds/CompaniesTableSeeder.php b/database/seeds/CompaniesTableSeeder.php index eacee77f..5b22ffc4 100644 --- a/database/seeds/CompaniesTableSeeder.php +++ b/database/seeds/CompaniesTableSeeder.php @@ -1,5 +1,9 @@ create(); + + $company = new Company(); + $company->reference_no = 1000000000; + $company->name = 'CIEF Worldwide SDN BHD'; + $company->type = CompanyTypes::COMPANY_BUSINESS; + $company->status = AccountStatus::ACTIVE; + $company->save(); + + $company->modules()->create(['module_type' => ModuleTypes::FORWARDER]); + + +// if (app()->environment('local')) +// factory(App\Models\Company::class, 30)->create(); } } diff --git a/database/seeds/ContactsTableSeeder.php b/database/seeds/ContactsTableSeeder.php index 12cf6dbb..9629b858 100644 --- a/database/seeds/ContactsTableSeeder.php +++ b/database/seeds/ContactsTableSeeder.php @@ -11,6 +11,7 @@ class ContactsTableSeeder extends Seeder */ public function run() { - factory(App\Models\Contact::class, 30)->create(); + if (app()->environment('local')) + factory(App\Models\Contact::class, 30)->create(); } } diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php index 29cd02e7..a55a3f93 100644 --- a/database/seeds/UsersTableSeeder.php +++ b/database/seeds/UsersTableSeeder.php @@ -24,18 +24,10 @@ class UsersTableSeeder extends Seeder 'role_id' => Roles::SUPER_ADMIN, 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now() - ], - [ - 'name' => 'Development User', - 'email' => env('EMAIL_DEVELOPMENT', 'dev@izyim.com'), - 'password' => Hash::make('123456abcabc'), - 'email_verified_at' => \Carbon\Carbon::now(), - 'role_id' => Roles::ADMIN, - 'created_at' => \Carbon\Carbon::now(), - 'updated_at' => \Carbon\Carbon::now() ] ]); - factory(App\Models\User::class, 30)->create(); + if (app()->environment('local')) + factory(App\Models\User::class, 30)->create(); } } diff --git a/resources/assets/vue/components/authentication/forms/ForgetPasswordFormComponent.vue b/resources/assets/vue/components/authentication/forms/ForgetPasswordFormComponent.vue index 2ea573aa..88f4f169 100644 --- a/resources/assets/vue/components/authentication/forms/ForgetPasswordFormComponent.vue +++ b/resources/assets/vue/components/authentication/forms/ForgetPasswordFormComponent.vue @@ -26,7 +26,7 @@
Back to login
-
Request Reset Link
+
Request Reset Link
diff --git a/resources/assets/vue/components/authentication/forms/LoginFormComponent.vue b/resources/assets/vue/components/authentication/forms/LoginFormComponent.vue index b6a73184..dc01aeba 100644 --- a/resources/assets/vue/components/authentication/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/authentication/forms/LoginFormComponent.vue @@ -42,7 +42,7 @@
-
Login
+
Login
Forgot Password ? diff --git a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue index 1d42ffe8..6ad03c18 100644 --- a/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue +++ b/resources/assets/vue/components/authentication/forms/RegistrationFormComponent.vue @@ -7,23 +7,27 @@
-
-
-

To start, how may we address you?

-
-
-
+
-
-
-
-
-
+
+
+

To start, how may we address you?

+
+
+
+
+
+
+
+
+
- - + + +
+
@@ -31,51 +35,82 @@
-
-
-
Next
-
-
-
-
-
-
-
-
-

Select an account type from one of the options below

-
-
-
-
+
+
-
-
-
- -
-

Personal

-
+
+

Select an account type from one of the options below

-
-
-
- +
+
+
+
+
+
+
+ +
+

Company

+
+
+
+
+
+ +
+

Personal

+
-

Business

+
+
+
+
+

What is your organization name?

+
+
+
+
+
+
+
+
+
+ + + + + +
+
+
+
+
+
+
+
+
+
+
+
Next
+
+
+ I already have an account +
+
-
+
@@ -116,18 +151,9 @@
-
-
-
Next
-
-
-
-
-
-
-
+
-

To help us server you better, please provide us with your contact information

+

Finally, Help us secure your account

@@ -140,7 +166,7 @@ - +
@@ -155,7 +181,7 @@ - +
@@ -170,6 +196,9 @@
Complete
+
+ Go Back +
@@ -181,7 +210,7 @@