mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
bulk commit
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use App\Classes\Modules\Accounts\Services\CreatesUser;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanCreateUser;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\ConnectionObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmployeeObject;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\ModuleObject;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyConnection;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyEmployee;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompanyModule;
|
||||
use App\Classes\Modules\Companies\Services\GeneratesUniqueAccountNumber;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Classes\ValueObjects\Constants\CompanyRoles;
|
||||
use App\Classes\ValueObjects\Constants\ModuleTypes;
|
||||
use App\Classes\ValueObjects\Constants\Notifications;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return Notifications::REGISTRATION;
|
||||
}
|
||||
|
||||
/** @var GeneratesUniqueAccountNumber */
|
||||
private $generatesUniqueAccountNumber;
|
||||
|
||||
/** @var CanCreateUser */
|
||||
private $canCreateUser;
|
||||
|
||||
/** @var CreatesUser */
|
||||
private $createsUser;
|
||||
|
||||
/** @var CreateCompanyProcessor */
|
||||
private $createCompanyProcessor;
|
||||
|
||||
/** @var CreatesCompanyModule */
|
||||
private $createsCompanyModule;
|
||||
|
||||
/** @var CreatesCompanyEmployee */
|
||||
private $createsCompanyEmployee;
|
||||
|
||||
/** @var CreatesCompanyConnection */
|
||||
private $createsCompanyConnection;
|
||||
|
||||
/** @var CreateContactProcessor */
|
||||
private $createContactProcessor;
|
||||
|
||||
/** @var AuthenticateUserLogic */
|
||||
private $authenticateUserLogic;
|
||||
|
||||
/**
|
||||
* CreateUserLogic constructor.
|
||||
* @param GeneratesUniqueAccountNumber $generatesUniqueAccountNumber
|
||||
* @param CanCreateUser $canCreateUser
|
||||
* @param CreatesUser $createsUser
|
||||
* @param CreateCompanyProcessor $createCompanyProcessor
|
||||
* @param CreatesCompanyModule $createsCompanyModule
|
||||
* @param CreatesCompanyEmployee $createsCompanyEmployee
|
||||
* @param CreatesCompanyConnection $createsCompanyConnection
|
||||
* @param CreateContactProcessor $createContactProcessor
|
||||
* @param AuthenticateUserLogic $authenticateUserLogic
|
||||
*/
|
||||
public function __construct(GeneratesUniqueAccountNumber $generatesUniqueAccountNumber, CanCreateUser $canCreateUser, CreatesUser $createsUser, CreateCompanyProcessor $createCompanyProcessor, CreatesCompanyModule $createsCompanyModule, CreatesCompanyEmployee $createsCompanyEmployee, CreatesCompanyConnection $createsCompanyConnection, CreateContactProcessor $createContactProcessor, AuthenticateUserLogic $authenticateUserLogic)
|
||||
{
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -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
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class RegistrationObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/** @var string */
|
||||
private $confirmPassword;
|
||||
|
||||
/**
|
||||
* RegistrationObject constructor.
|
||||
* @param string $email
|
||||
* @param string $name
|
||||
* @param string $password
|
||||
* @param string $confirmPassword
|
||||
*/
|
||||
public function __construct(string $email, string $name, string $password, string $confirmPassword)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use App\Classes\ValueObjects\Constants\Roles;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class CreatesUser extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param RegistrationObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model|null
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(RegistrationObject $object){
|
||||
$model = new User();
|
||||
$model->email = $object->getEmail();
|
||||
$model->name = $object->getName();
|
||||
$model->password = Hash::make($object->getPassword());
|
||||
$model->role_id = Roles::USER;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Standards\Validators\UserAuthenticationValidation;
|
||||
use App\Classes\Modules\Accounts\Standards\Validators\UserRegistrationValidation;
|
||||
|
||||
class CanCreateUser extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var UserRegistrationValidation */
|
||||
private $userRegistrationValidation;
|
||||
|
||||
/**
|
||||
* CanRegisterUser constructor.
|
||||
* @param UserRegistrationValidation $userRegistrationValidation
|
||||
*/
|
||||
public function __construct(UserRegistrationValidation $userRegistrationValidation)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
|
||||
class UserRegistrationValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param AuthenticationCredentialsObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array {
|
||||
return [
|
||||
'email' => $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 [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllerLogic;
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -12,7 +12,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateAddressControllerLogic extends AbstractControllerLogic
|
||||
class CreateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllerLogic;
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteAddressControllerLogic extends AbstractControllerLogic
|
||||
class DeleteAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllerLogic;
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -12,7 +12,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchAddressControllerLogic extends AbstractControllerLogic
|
||||
class FetchAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllerLogic;
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListAddressesControllerLogic extends AbstractControllerLogic
|
||||
class ListAddressesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ class ListAddressesControllerLogic extends AbstractControllerLogic
|
||||
private $listsAddresses;
|
||||
|
||||
/**
|
||||
* ListAddressesControllerLogic constructor.
|
||||
* ListAddressesLogic constructor.
|
||||
* @param CanListAddresses $canListAddresses
|
||||
* @param ListsAddresses $listsAddresses
|
||||
*/
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Addresses\ControllerLogic;
|
||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -13,7 +13,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateAddressControllerLogic extends AbstractControllerLogic
|
||||
class UpdateAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ class UpdateAddressControllerLogic extends AbstractControllerLogic
|
||||
private $fetchesAddress;
|
||||
|
||||
/**
|
||||
* UpdateAddressControllerLogic constructor.
|
||||
* UpdateAddressLogic constructor.
|
||||
* @param CanUpdateAddress $canUpdateAddress
|
||||
* @param UpdatesAddress $updatesAddress
|
||||
* @param FetchesAddress $fetchesAddress
|
||||
@@ -9,6 +9,11 @@ use App\Models\Address;
|
||||
class CreatesAddress extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param AddressObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(AddressObject $object) {
|
||||
$model = new Address();
|
||||
$model->company_id = $object->getCompanyId();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyControllerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
|
||||
use App\Http\Resources\CompanyResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllerLogic;
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteCompanyControllerLogic extends AbstractControllerLogic
|
||||
class DeleteCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
@@ -34,7 +34,7 @@ class DeleteCompanyControllerLogic extends AbstractControllerLogic
|
||||
private $fetchesCompany;
|
||||
|
||||
/**
|
||||
* DeleteCompanyControllerLogic constructor.
|
||||
* DeleteCompanyLogic constructor.
|
||||
* @param CanDeleteCompany $canDeleteCompany
|
||||
* @param DeletesCompany $deletesCompany
|
||||
* @param FetchesCompany $fetchesCompany
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllerLogic;
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -12,7 +12,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchCompanyControllerLogic extends AbstractControllerLogic
|
||||
class FetchCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllerLogic;
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListCompaniesControllerLogic extends AbstractControllerLogic
|
||||
class ListCompaniesLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllerLogic;
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -13,7 +13,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateCompanyControllerLogic extends AbstractControllerLogic
|
||||
class UpdateCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -7,22 +7,22 @@ use App\Classes\Interfaces\DataTransferObject;
|
||||
class CompanyObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var integer */
|
||||
/** @var int */
|
||||
private $referenceNo;
|
||||
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var integer */
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* CompanyObject constructor.
|
||||
* @param integer $referenceNo
|
||||
* @param string $name
|
||||
* @param integer $type
|
||||
* @param int $referenceNo
|
||||
* @param string $name
|
||||
* @param int $type
|
||||
*/
|
||||
public function __construct(integer $referenceNo, string $name, integer $type)
|
||||
public function __construct(int $referenceNo, string $name, int $type)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class ConnectionObject
|
||||
{
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $inviter;
|
||||
|
||||
/** @var CompanyModule */
|
||||
private $invitee;
|
||||
|
||||
/**
|
||||
* ConnectionObject constructor.
|
||||
* @param CompanyModule $inviter
|
||||
* @param CompanyModule $invitee
|
||||
*/
|
||||
public function __construct(CompanyModule $inviter, CompanyModule $invitee)
|
||||
{
|
||||
$this->inviter = $inviter;
|
||||
$this->invitee = $invitee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompanyModule
|
||||
*/
|
||||
public function getInviter(): CompanyModule
|
||||
{
|
||||
return $this->inviter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CompanyModule
|
||||
*/
|
||||
public function getInvitee(): CompanyModule
|
||||
{
|
||||
return $this->invitee;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
|
||||
class EmployeeObject implements DataTransferObject
|
||||
{
|
||||
/** @var CompanyModule */
|
||||
private $companyModule;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/** @var int */
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* EmployeeObject constructor.
|
||||
* @param CompanyModule $companyModule
|
||||
* @param User $user
|
||||
* @param int $role
|
||||
*/
|
||||
public function __construct(CompanyModule $companyModule, User $user, int $role)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\DataTransferObjects;
|
||||
|
||||
|
||||
use App\Models\Company;
|
||||
|
||||
class ModuleObject
|
||||
{
|
||||
|
||||
/** @var Company */
|
||||
private $company;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* ModuleObject constructor.
|
||||
* @param Company $company
|
||||
* @param int $type
|
||||
*/
|
||||
public function __construct(Company $company, int $type)
|
||||
{
|
||||
$this->company = $company;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Company
|
||||
*/
|
||||
public function getCompany(): Company
|
||||
{
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Classes\Modules\Companies\Services\CreatesCompany;
|
||||
use App\Classes\Modules\Companies\Services\GeneratesUniqueAccountNumber;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanCreateCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCompanyProcessor
|
||||
{
|
||||
|
||||
/** @var CanCreateCompany */
|
||||
private $canCreateCompany;
|
||||
|
||||
/** @var CreatesCompany */
|
||||
private $createsCompany;
|
||||
|
||||
/** @var GeneratesUniqueAccountNumber */
|
||||
private $generatesUniqueAccountNumber;
|
||||
|
||||
/**
|
||||
* CreateCompanyLogic constructor.
|
||||
* @param CanCreateCompany $canCreateCompany
|
||||
* @param CreatesCompany $createsCompany
|
||||
* @param GeneratesUniqueAccountNumber $generatesUniqueAccountNumber
|
||||
*/
|
||||
public function __construct(CanCreateCompany $canCreateCompany, CreatesCompany $createsCompany, GeneratesUniqueAccountNumber $generatesUniqueAccountNumber)
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Models\Company;
|
||||
|
||||
class ChecksIfCompanyAccountNumberExists
|
||||
{
|
||||
|
||||
/** @var Company */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ChecksIfAccountNumberExists constructor.
|
||||
* @param Company $repository
|
||||
*/
|
||||
public function __construct(Company $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function execute(int $accountNumber): bool {
|
||||
return $this->repository->where('reference_no', $accountNumber)->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\ConnectionObject;
|
||||
use App\Classes\ValueObjects\Constants\ConnectionStatus;
|
||||
|
||||
class CreatesCompanyConnection
|
||||
{
|
||||
|
||||
public function execute(ConnectionObject $connection){
|
||||
$connection->getInviter()->connections()->attach($connection->getInvitee(),
|
||||
[
|
||||
'status' => ConnectionStatus::APPROVED,
|
||||
'instigator' => $connection->getInvitee()->id
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\EmployeeObject;
|
||||
|
||||
class CreatesCompanyEmployee
|
||||
{
|
||||
|
||||
public function execute(EmployeeObject $employee){
|
||||
$employee->getCompanyModule()->employees()->attach($employee->getUser(), [
|
||||
'role_id' => $employee->getRole(),
|
||||
'active' => true
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\ModuleObject;
|
||||
|
||||
class CreatesCompanyModule extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param ModuleObject $module
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ModuleObject $module){
|
||||
|
||||
$model = $module->getCompany()->modules()->create(['module_type' => $module->getType()]);
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
|
||||
class GeneratesUniqueAccountNumber
|
||||
{
|
||||
|
||||
/** @var ChecksIfCompanyAccountNumberExists */
|
||||
private $accountNumberExists;
|
||||
|
||||
/**
|
||||
* GeneratesUniqueAccountNumber constructor.
|
||||
* @param ChecksIfCompanyAccountNumberExists $accountNumberExists
|
||||
*/
|
||||
public function __construct(ChecksIfCompanyAccountNumberExists $accountNumberExists)
|
||||
{
|
||||
$this->accountNumberExists = $accountNumberExists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function execute(): int {
|
||||
|
||||
$number = mt_rand(100000001, 999999999);
|
||||
return !$this->accountNumberExists->execute($number) ? $number : self::execute();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContactControllerLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContactLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DeleteContactControllerLogic extends AbstractControllerLogic
|
||||
class DeleteContactLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -12,7 +12,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchContactControllerLogic extends AbstractControllerLogic
|
||||
class FetchContactLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -11,7 +11,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListContactsControllerLogic extends AbstractControllerLogic
|
||||
class ListContactsLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\ControllerLogic;
|
||||
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -13,7 +13,7 @@ use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateContactControllerLogic extends AbstractControllerLogic
|
||||
class UpdateContactLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Contacts\Processors;
|
||||
|
||||
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
||||
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContactProcessor
|
||||
{
|
||||
/** @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 \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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
class CompanyRoles
|
||||
{
|
||||
|
||||
public const OWNER = 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
class CompanyTypes
|
||||
{
|
||||
|
||||
public const PERSONAL_BUSINESS = 0;
|
||||
|
||||
public const COMPANY_BUSINESS = 1;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
class ConnectionStatus
|
||||
{
|
||||
|
||||
public const PENDING_APPROVAL = 0;
|
||||
|
||||
public const APPROVED = 1;
|
||||
|
||||
public const REJECTED = 2;
|
||||
|
||||
public const BLOCKED = 3;
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class ModularTypes {
|
||||
|
||||
public const CLIENT_MODULE = 1;
|
||||
public const PROJECT_MODULE = 2;
|
||||
public const TASK_MODULE = 3;
|
||||
public const TICKET_MODULE = 4;
|
||||
public const DOCUMENT_MODULE = 5;
|
||||
public const FIELD_MODULE = 0;
|
||||
|
||||
public const MODULAR_MODULES = [
|
||||
'client' => 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;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
final class ModuleTypes
|
||||
{
|
||||
|
||||
public const IMPORTER = 0;
|
||||
|
||||
public const FORWARDER = 1;
|
||||
|
||||
}
|
||||
@@ -16,6 +16,11 @@ class Notifications
|
||||
'message' => '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'
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
|
||||
final class RelationStatus
|
||||
{
|
||||
|
||||
public const PENDING = 0;
|
||||
|
||||
public const ACCEPTED = 1;
|
||||
|
||||
public const DECLINED = 2;
|
||||
|
||||
public const BLOCKED = 3;
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account\Authentication;
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\CheckEmailLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\CreateUserLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateUserController
|
||||
{
|
||||
public function create(Request $request, CreateUserLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account\Authentication;
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\GeneratePasswordResetLogic;
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account\User;
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\ListUsersControllerLogic;
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\ListUsersLogic;
|
||||
use App\Classes\Modules\Accounts\Services\ListsUsers;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,7 +23,7 @@ class ListUsersController
|
||||
}
|
||||
|
||||
|
||||
public function list(Request $request, ListUsersControllerLogic $logic): JsonResponse {
|
||||
public function list(Request $request, ListUsersLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account\Authentication;
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\ResetPasswordLogic;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account\Authentication;
|
||||
namespace App\Http\Controllers\Account;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\AuthenticateUserLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Addresses;
|
||||
|
||||
use App\Classes\Modules\Addresses\ControllerLogic\CreateAddressControllerLogic;
|
||||
use App\Classes\Modules\Addresses\ControllersLogic\CreateAddressLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -10,10 +10,10 @@ class CreateAddressController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param CreateAddressControllerLogic $logic
|
||||
* @param CreateAddressLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreateAddressControllerLogic $logic): JsonResponse {
|
||||
public function create(Request $request, CreateAddressLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+2
-47
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+29
-29
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* Class CompanyConnections
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:21 am
|
||||
*
|
||||
* @property string name
|
||||
* @property integer type
|
||||
*/
|
||||
class CompanyConnections extends AbstractModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'company_connections';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function companyModule(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CompanyModule::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* Class CompanyEmployee
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:21 am
|
||||
*
|
||||
* @property string name
|
||||
* @property integer type
|
||||
*/
|
||||
class CompanyEmployee extends AbstractModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'company_employees';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $fillable = [
|
||||
'user_id'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return HasOneThrough
|
||||
*/
|
||||
public function company(): hasOneThrough
|
||||
{
|
||||
return $this->hasOneThrough(Company::class, CompanyModule::class);
|
||||
}
|
||||
|
||||
public function user(): belongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\AbstractModel as Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* Class CompanyModule
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:21 am
|
||||
*
|
||||
* @property string name
|
||||
* @property integer type
|
||||
*/
|
||||
class CompanyModule extends AbstractModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'company_modules';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
public $fillable = [
|
||||
'module_type'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->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');
|
||||
}
|
||||
|
||||
}
|
||||
+2
-34
@@ -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');
|
||||
|
||||
@@ -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'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
+7
-26
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\Roles;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -19,7 +20,7 @@ class CreateUsersTable extends Migration
|
||||
$table->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();
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUserEmailVerificationsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_email_verifications', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AccountStatus;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
@@ -18,8 +19,8 @@ class CreateCompaniesTable extends Migration
|
||||
$table->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();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ModuleTypes;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateCompanyModulesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('company_modules', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\RelationStatus;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateCompanyConnectionsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('company_connections', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateCompanyEmployeesTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('company_employees', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrderTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('order', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AccountStatus;
|
||||
use App\Classes\ValueObjects\Constants\CompanyTypes;
|
||||
use App\Classes\ValueObjects\Constants\ModuleTypes;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CompaniesTableSeeder extends Seeder
|
||||
@@ -11,6 +15,18 @@ class CompaniesTableSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
factory(App\Models\Company::class, 30)->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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<div class="b-t b-b b-r b-grey all-caps muted p-t-15 p-b-15 p-l-30 p-r-20 font-lato pointer fs-12" @click="$store.dispatch('toggleSection', {name: 'forgetPassword', status: false})" style="letter-spacing: 2px;"><i class="fa fa-angle-left" style="padding-right: 18px;"></i>Back to login</div>
|
||||
</div>
|
||||
<div class="col-auto ml-auto p-r-0 animated fadeInRightBig slow">
|
||||
<div class="bg-success all-caps text-white p-t-15 p-b-15 p-l-50 p-r-20 bold font-lato pointer fs-12" style="letter-spacing: 4px;" @click="submit(route('api.account.password.forget'), 'post', section, false , false)">Request Reset Link</div>
|
||||
<div class="bg-success all-caps text-white p-t-15 p-b-15 p-l-50 p-r-20 bold font-lato pointer fs-12" style="letter-spacing: 4px;" @click="submit(route('api.account.authentication.password.forget'), 'post', section, false , false)">Request Reset Link</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user