mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Merge branch 'exchange-1-user-registration' into 'master'
Exchange 1 user registration See merge request CIEFWorldwideSdnBhd/exchange-2.0!2
This commit is contained in:
@@ -11,3 +11,4 @@ Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/storage/file
|
||||
|
||||
@@ -34,9 +34,9 @@ abstract class AbstractValidation
|
||||
* @return bool
|
||||
* @throws RequestValidationException
|
||||
*/
|
||||
public function validate(DataTransferObject $object){
|
||||
|
||||
$validator = $this->validator::make($this->data($object), $this->rules(), $this->messages());
|
||||
public function validate(DataTransferObject $object, ?string $type = 'POST')
|
||||
{
|
||||
$validator = $this->validator::make($this->data($object), $this->rules($type), $this->messages());
|
||||
|
||||
if($validator->fails()) {
|
||||
throw new RequestValidationException($validator->messages()->first());
|
||||
|
||||
@@ -122,7 +122,7 @@ class CreateUserLogic extends AbstractControllerLogic
|
||||
$company_object = new CompanyObject(
|
||||
$request->input('company_name'),
|
||||
$request->input('company_reference'),
|
||||
1
|
||||
null
|
||||
);
|
||||
|
||||
$this->canCreateCompany->passes($company_object);
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanCreateDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanCreateFile;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFile;
|
||||
use App\Classes\Modules\Documents\Services\Convert64ToFile;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OwnerType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ObjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\FileType;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RegistrationStep2Logic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Registration Step 2',
|
||||
'message' => 'You have completed registration step 2'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var CanCreateDocument */
|
||||
private $canCreateDocument;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CanCreateFile */
|
||||
private $canCreateFIle;
|
||||
|
||||
/** @var CreatesFile */
|
||||
private $createsFile;
|
||||
|
||||
/** @var Convert64ToFile */
|
||||
private $convert64ToFile;
|
||||
|
||||
/**
|
||||
* UpdateUserControllerLogic constructor.
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param CanCreateDocument $canCreateDocument
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CanCreateFile $canCreateFile
|
||||
* @param CreatesFile $createsFile
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesUser $fetchesUser,
|
||||
CanUpdateCompany $canUpdateCompany,
|
||||
UpdatesCompany $updatesCompany,
|
||||
CanCreateDocument $canCreateDocument,
|
||||
CreatesDocument $createsDocument,
|
||||
CanCreateFile $canCreateFile,
|
||||
CreatesFile $createsFile,
|
||||
Convert64ToFile $convert64ToFile
|
||||
)
|
||||
{
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->canCreateDocument = $canCreateDocument;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->canCreateFile = $canCreateFile;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->convert64ToFile = $convert64ToFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$user_query = $this->fetchesUser->execute(['id' => \Auth::user()->id]);
|
||||
$company_query = $user_query->company()->first();
|
||||
|
||||
$company_object = new CompanyObject(
|
||||
$request->input('company_name', $company_query->name),
|
||||
$request->input('company_reference', $company_query->refence),
|
||||
$request->input('type', $company_query->type)
|
||||
);
|
||||
$this->canUpdateCompany->passes($company_object);
|
||||
$company_query = $this->updatesCompany->execute($company_query, $company_object);
|
||||
|
||||
$document_type = $company_query->type == 1 ? DocumentType::COMPANY_PUBLIC_SMS_REGISTER : DocumentType::COMPANY_PERSONAL_IC;
|
||||
$document_object = new DocumentObject(
|
||||
$user_query->id,
|
||||
OwnerType::COMPANY,
|
||||
$document_type,
|
||||
$request->input('document_reference'),
|
||||
ObjectStatus::PENDING,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
$this->canCreateDocument->passes($document_object);
|
||||
$document_query = $this->createsDocument->execute($document_object);
|
||||
|
||||
$file = $this->convert64ToFile->convert($request->input('file'));
|
||||
$file_type = $company_query->type == 1 ? FileType::COMPANY_PUBLIC_SMS_REGISTER : FileType::COMPANY_PERSONAL_IC;
|
||||
|
||||
$file_object = new FileObject(
|
||||
$document_query->id,
|
||||
!empty($file[0]) ? json_encode($file[0]) : null,
|
||||
$file_type
|
||||
);
|
||||
$this->canCreateFile->passes($file_object);
|
||||
$file_query = $this->createsFile->execute($file_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new UserResource(\Auth::user()));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompany;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanCreateDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanCreateFile;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFile;
|
||||
use App\Classes\Modules\Documents\Services\Convert64ToFile;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OwnerType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ObjectStatus;
|
||||
use App\Classes\ValueObjects\Constants\FileType;
|
||||
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateUserLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update User',
|
||||
'message' => 'You have successfully update a user'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var CanUpdateCompany */
|
||||
private $canUpdateCompany;
|
||||
|
||||
/** @var UpdatesCompany */
|
||||
private $updatesCompany;
|
||||
|
||||
/** @var CanCreateDocument */
|
||||
private $canCreateDocument;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CanCreateFile */
|
||||
private $canCreateFIle;
|
||||
|
||||
/** @var CreatesFile */
|
||||
private $createsFile;
|
||||
|
||||
/** @var Convert64ToFile */
|
||||
private $convert64ToFile;
|
||||
|
||||
/**
|
||||
* UpdateUserControllerLogic constructor.
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param CanUpdateCompany $canUpdateCompany
|
||||
* @param UpdatesCompany $updatesCompany
|
||||
* @param CanCreateDocument $canCreateDocument
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CanCreateFile $canCreateFile
|
||||
* @param CreatesFile $createsFile
|
||||
*/
|
||||
public function __construct(
|
||||
FetchesUser $fetchesUser,
|
||||
CanUpdateCompany $canUpdateCompany,
|
||||
UpdatesCompany $updatesCompany,
|
||||
CanCreateDocument $canCreateDocument,
|
||||
CreatesDocument $createsDocument,
|
||||
CanCreateFile $canCreateFile,
|
||||
CreatesFile $createsFile,
|
||||
Convert64ToFile $convert64ToFile
|
||||
)
|
||||
{
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->canUpdateCompany = $canUpdateCompany;
|
||||
$this->updatesCompany = $updatesCompany;
|
||||
$this->canCreateDocument = $canCreateDocument;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->canCreateFile = $canCreateFile;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->convert64ToFile = $convert64ToFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$user_query = $this->fetchesUser->execute(['id' => \Auth::user()->id]);
|
||||
$company_query = $user_query->company()->first();
|
||||
|
||||
$company_object = new CompanyObject(
|
||||
$request->input('company_name', $company_query->name),
|
||||
$request->input('company_reference', $company_query->refence),
|
||||
$request->input('type', $company_query->type)
|
||||
);
|
||||
$this->canUpdateCompany->passes($company_object);
|
||||
$company_query = $this->updatesCompany->execute($company_query, $company_object);
|
||||
|
||||
$document_type = $company_query->type == 1 ? DocumentType::COMPANY_PUBLIC_SMS_REGISTER : DocumentType::COMPANY_PERSONAL_IC;
|
||||
$document_object = new DocumentObject(
|
||||
$user_query->id,
|
||||
OwnerType::COMPANY,
|
||||
$document_type,
|
||||
$request->input('document_reference'),
|
||||
ObjectStatus::PENDING,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
$this->canCreateDocument->passes($document_object);
|
||||
$document_query = $this->createsDocument->execute($document_object);
|
||||
|
||||
$file = $this->convert64ToFile->convert($request->input('file'));
|
||||
$file_type = $company_query->type == 1 ? FileType::COMPANY_PUBLIC_SMS_REGISTER : FileType::COMPANY_PERSONAL_IC;
|
||||
|
||||
$file_object = new FileObject(
|
||||
$document_query->id,
|
||||
!empty($file[0]) ? json_encode($file[0]) : null,
|
||||
$file_type
|
||||
);
|
||||
$this->canCreateFile->passes($file_object);
|
||||
$file_query = $this->createsFile->execute($file_object);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->resourceResponse(new UserResource(\Auth::user()));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\User;
|
||||
|
||||
class FetchesUser extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesUser constructor.
|
||||
* @param User $repository
|
||||
*/
|
||||
public function __construct(User $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class CompanyObject implements DataTransferObject
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
public function getType(): ?int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||
use App\Models\Company;
|
||||
|
||||
class UpdatesCompany extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CompanyObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Company $model, CompanyObject $object)
|
||||
{
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
$model->type = $object->getType();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Standards\Rules;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Companies\DataTransferObjects\UserObject;
|
||||
use App\Classes\Modules\Companies\Standards\Validators\CompanyValidation;
|
||||
|
||||
class CanUpdateCompany extends AbstractRule
|
||||
{
|
||||
/** @var CompanyValidation */
|
||||
private $companyValidation;
|
||||
|
||||
/**
|
||||
* CanCreateUser constructor.
|
||||
* @param CompanyValidation $companyValidation
|
||||
*/
|
||||
public function __construct(CompanyValidation $companyValidation)
|
||||
{
|
||||
$this->companyValidation = $companyValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->companyValidation->validate($object, 'PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,23 @@ class CompanyValidation extends AbstractValidation
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
protected function rules(?string $type = 'POST'): array
|
||||
{
|
||||
return [
|
||||
'company_name' => 'required',
|
||||
'company_reference' => '',
|
||||
'type' => 'required'
|
||||
];
|
||||
if ($type == 'POST') {
|
||||
return [
|
||||
'company_name' => 'required',
|
||||
'company_reference' => '',
|
||||
'type' => ''
|
||||
];
|
||||
}
|
||||
elseif($type == 'PUT') {
|
||||
return [
|
||||
'type' => 'required'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class DocumentObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $owner_id;
|
||||
|
||||
/** @var int|null */
|
||||
private $owner_type;
|
||||
|
||||
/** @var string|null */
|
||||
private $document_type;
|
||||
|
||||
/** @var string|null */
|
||||
private $reference;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/** @var int|null */
|
||||
private $approved_by;
|
||||
|
||||
/** @var timestamp|null */
|
||||
private $issued_date;
|
||||
|
||||
/** @var timestamp|null */
|
||||
private $expired_date;
|
||||
|
||||
/** @var timestamp|null */
|
||||
private $approved_date;
|
||||
|
||||
/**
|
||||
* CompanyObject constructor.
|
||||
* @param int|null $country_id
|
||||
* @param int|null $company_id
|
||||
* @param string|null $reference
|
||||
* @param string|null $phone
|
||||
* @param string|null $email
|
||||
* @param string|null $wechat_id
|
||||
*/
|
||||
public function __construct(
|
||||
?int $owner_id,
|
||||
?int $owner_type,
|
||||
?string $document_type,
|
||||
?string $reference,
|
||||
?int $status,
|
||||
?int $approved_by,
|
||||
?timestamp $issued_date,
|
||||
?timestamp $expired_date,
|
||||
?timestamp $approved_date
|
||||
)
|
||||
{
|
||||
$this->owner_id = $owner_id;
|
||||
$this->owner_type = $owner_type;
|
||||
$this->document_type = $document_type;
|
||||
$this->reference = $reference;
|
||||
$this->status = $status;
|
||||
$this->approved_by = $approved_by;
|
||||
$this->issued_date = $issued_date;
|
||||
$this->expired_date = $expired_date;
|
||||
$this->approved_date = $approved_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOwnerId(): ?int
|
||||
{
|
||||
return $this->owner_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getOwnerType(): ?int
|
||||
{
|
||||
return $this->owner_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDocumentType(): ?string
|
||||
{
|
||||
return $this->document_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatus(): ?int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getApprovedBy(): ?int
|
||||
{
|
||||
return $this->approved_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return timestamp|null
|
||||
*/
|
||||
public function getIssuedDate(): ?timestamp
|
||||
{
|
||||
return $this->issued_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return timestamp|null
|
||||
*/
|
||||
public function getExpiredDate(): ?timestamp
|
||||
{
|
||||
return $this->expired_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return timestamp|null
|
||||
*/
|
||||
public function getApprovedDate(): ?timestamp
|
||||
{
|
||||
return $this->approved_date;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
|
||||
use App\Classes\Interfaces\DataTransferObject;
|
||||
|
||||
class FileObject implements DataTransferObject
|
||||
{
|
||||
/** @var int|null */
|
||||
private $document_id;
|
||||
|
||||
/** @var text|null */
|
||||
private $file;
|
||||
|
||||
/** @var string|null */
|
||||
private $file_type;
|
||||
|
||||
/**
|
||||
* CompanyObject constructor.
|
||||
* @param int|null $document_id
|
||||
* @param text|null $file
|
||||
* @param string|null $file_type
|
||||
*/
|
||||
public function __construct(
|
||||
?int $document_id,
|
||||
?string $file,
|
||||
?string $file_type
|
||||
)
|
||||
{
|
||||
$this->document_id = $document_id;
|
||||
$this->file = $file;
|
||||
$this->file_type = $file_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getDocumentId(): ?int
|
||||
{
|
||||
return $this->document_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFile(): ?string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileType(): ?string
|
||||
{
|
||||
return $this->file_type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Image;
|
||||
|
||||
class Convert64ToFile
|
||||
{
|
||||
/**
|
||||
* @param array|null file_set
|
||||
*/
|
||||
public function convert($file_set = [], $path = 'file')
|
||||
{
|
||||
$file_info = [];
|
||||
$folder_path = $this->generateFolder($path);
|
||||
|
||||
foreach ($file_set as $key => $row) {
|
||||
|
||||
$file_data = $row;
|
||||
$filename = (string) Str::uuid();
|
||||
|
||||
$f = finfo_open();
|
||||
$mime_type = finfo_file($f, $file_data, FILEINFO_MIME_TYPE);
|
||||
|
||||
$extension = '';
|
||||
switch ($mime_type) {
|
||||
case 'image/gif':
|
||||
$extension = 'gif';
|
||||
break;
|
||||
case 'image/png':
|
||||
$extension = 'png';
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
$extension = 'jpg';
|
||||
break;
|
||||
case 'application/pdf':
|
||||
$extension = 'pdf';
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($extension)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename_with_ext = $filename . '.' . $extension;
|
||||
|
||||
if ($extension != 'pdf') {
|
||||
$img = Image::make($file_data)->save($folder_path . '/' . $filename_with_ext);
|
||||
$file = $this->generateImages($path, $filename_with_ext, $filename, $extension);
|
||||
}
|
||||
else {
|
||||
$file_data = explode('base64,', $file_data);
|
||||
$file_data = base64_decode($file_data[1]);
|
||||
$file = $this->generatePdf($path, $file_data, $filename, $extension);
|
||||
}
|
||||
|
||||
$file_info[] = [
|
||||
'path' => $path,
|
||||
'filename' => $filename_with_ext,
|
||||
'mime_type' => $mime_type,
|
||||
'extension' => $extension,
|
||||
'file_info' => empty($file) ? [] : $file,
|
||||
];
|
||||
}
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null path
|
||||
* @param string|null pdfdata
|
||||
* @param string|null filename
|
||||
* @param string|null extension
|
||||
*/
|
||||
public static function generatePdf($path = '', $pdfdata = '', $filename = '', $extension = '')
|
||||
{
|
||||
$file_info = [];
|
||||
$file = \File::put(storage_path($path) . '/' . $filename . '.' . $extension, $pdfdata);
|
||||
$file_info['original']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
|
||||
$file_info['large']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
|
||||
$file_info['medium']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
|
||||
$file_info['small']['file'] = 'storage/' . $path . '/' . $filename . '.' . $extension;
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null path
|
||||
* @param string|null file
|
||||
* @param string|null filename
|
||||
* @param string|null extension
|
||||
*/
|
||||
public function generateImages($path = '', $file = '', $filename = '', $extension = '')
|
||||
{
|
||||
$file_info = [];
|
||||
|
||||
$img = Image::make(storage_path($path) . '/' . $file);
|
||||
$file_info['original']['file'] = 'storage/' . $path . '/' . $file;
|
||||
$file_info['original']['width'] = $img->width();
|
||||
$file_info['original']['height'] = $img->height();
|
||||
|
||||
$img->widen(800, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
})->heighten(800, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
});
|
||||
$img->save(storage_path($path) . '/' . $filename . '_' . 'l.' . $extension);
|
||||
$file_info['large']['file'] = 'storage/' . $path . '/' . $filename . '_' . 'l.' . $extension;
|
||||
$file_info['large']['width'] = $img->width();
|
||||
$file_info['large']['height'] = $img->height();
|
||||
|
||||
$img->widen(480, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
})->heighten(480, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
});
|
||||
$img->save(storage_path($path) . '/' . $filename . '_' . 'm.' . $extension);
|
||||
$file_info['medium']['file'] = 'storage/' . $path . '/' . $filename . '_' . 'm.' . $extension;
|
||||
$file_info['medium']['width'] = $img->width();
|
||||
$file_info['medium']['height'] = $img->height();
|
||||
|
||||
$img->widen(320, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
})->heighten(320, function ($constraint) {
|
||||
$constraint->upsize();
|
||||
});
|
||||
$img->save(storage_path($path) . '/' . $filename . '_' . 's.' . $extension);
|
||||
$file_info['small']['file'] = 'storage/' . $path . '/' . $filename . '_' . 's.' . $extension;
|
||||
$file_info['small']['width'] = $img->width();
|
||||
$file_info['small']['height'] = $img->height();
|
||||
|
||||
return $file_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null set_path
|
||||
*/
|
||||
public function generateFolder($set_path = '')
|
||||
{
|
||||
$folder = storage_path($set_path);
|
||||
|
||||
\File::isDirectory($folder) or \File::makeDirectory($folder, 0777, true, true); //check folder is exist
|
||||
return $folder;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Models\Document;
|
||||
|
||||
class CreatesDocument extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(DocumentObject $object)
|
||||
{
|
||||
$model = new Document();
|
||||
$model->owner_id = $object->getOwnerId();
|
||||
$model->owner_type = $object->getOwnerType();
|
||||
$model->document_type = $object->getDocumentType();
|
||||
$model->reference = $object->getReference();
|
||||
$model->status = $object->getStatus();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
use App\Models\File;
|
||||
|
||||
class CreatesFile extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(FileObject $object)
|
||||
{
|
||||
$model = new File();
|
||||
$model->document_id = $object->getDocumentId();
|
||||
$model->file = $object->getFile();
|
||||
$model->file_type = $object->getFileType();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\DocumentValidation;
|
||||
|
||||
class CanCreateDocument extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var DocumentValidation */
|
||||
private $documentValidation;
|
||||
|
||||
/**
|
||||
* CanCreateAddress constructor.
|
||||
* @param DocumentValidation $documentValidation
|
||||
*/
|
||||
public function __construct(DocumentValidation $documentValidation)
|
||||
{
|
||||
$this->documentValidation = $documentValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->documentValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
use App\Classes\Modules\Documents\Standards\Validators\FileValidation;
|
||||
|
||||
class CanCreateFile extends AbstractRule
|
||||
{
|
||||
|
||||
/** @var FileValidation */
|
||||
private $fileValidation;
|
||||
|
||||
/**
|
||||
* CanCreateFile constructor.
|
||||
* @param FileValidation $fileValidation
|
||||
*/
|
||||
public function __construct(FileValidation $fileValidation)
|
||||
{
|
||||
$this->fileValidation = $fileValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return $this->fileValidation->validate($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class DocumentValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'owner_id' => $object->getOwnerId(),
|
||||
'owner_type' => $object->getOwnerType(),
|
||||
'document_type' => $object->getDocumentType(),
|
||||
'reference' => $object->getReference(),
|
||||
'status' => $object->getStatus(),
|
||||
'approved_by' => $object->getApprovedBy(),
|
||||
'issued_date' => $object->getIssuedDate(),
|
||||
'expired_date' => $object->getExpiredDate(),
|
||||
'approved_date' => $object->getApprovedDate()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'owner_id' => 'required',
|
||||
'owner_type' => 'required',
|
||||
'document_type' => 'required',
|
||||
'reference' => 'required',
|
||||
'status' => '',
|
||||
'issued_date' => '',
|
||||
'expired_date' => '',
|
||||
'approved_date' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\FileObject;
|
||||
|
||||
class FileValidation extends AbstractValidation
|
||||
{
|
||||
/**
|
||||
* @param FileObject $object
|
||||
* @return array
|
||||
*/
|
||||
protected function data($object): array
|
||||
{
|
||||
return [
|
||||
'document_id' => $object->getDocumentId(),
|
||||
'file' => $object->getFile(),
|
||||
'file_type' => $object->getFileType()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function rules(): array
|
||||
{
|
||||
return [
|
||||
'document_id' => 'required',
|
||||
'file' => 'required',
|
||||
'file_type' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function messages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class CompanyType {
|
||||
public const PUBLIC_COMPANY = 1;
|
||||
public const PERSONAL_COMPANY = 2;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class DocumentType {
|
||||
public const COMPANY_PUBLIC_SMS_REGISTER = 'COMPANY_PUBLIC_SMS_REGISTER';
|
||||
public const COMPANY_PERSONAL_IC = 'COMPANY_PERSONAL_IC';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class FileType {
|
||||
public const COMPANY_PUBLIC_SMS_REGISTER = 'COMPANY_PUBLIC_SMS_REGISTER';
|
||||
public const COMPANY_PERSONAL_IC = 'COMPANY_PERSONAL_IC';
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class ObjectStatus {
|
||||
public const PENDING = 9;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class OwnerType {
|
||||
public const COMPANY = 1;
|
||||
}
|
||||
@@ -16,5 +16,4 @@ class CreateUserController
|
||||
public function create(Request $request, CreateUserLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\RegistrationStep2Logic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RegistrationStep2Controller
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param RegistrationStep2Logic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, RegistrationStep2Logic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\UpdateUserLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateUserController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateUserLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateUserLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Account;
|
||||
namespace App\Http\Controllers\Accounts;
|
||||
|
||||
use App\Classes\Modules\Accounts\ControllersLogic\AuthenticateUserLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property int owner_type
|
||||
* @property int document_type
|
||||
* @property string reference
|
||||
* @property int status
|
||||
* @property \App\Models\User approved_by
|
||||
* @property timestamp issued_date
|
||||
* @property timestamp expired_date
|
||||
* @property timestamp approved_date
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class File
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Document document_id
|
||||
* @property text file
|
||||
* @property int file_type_id
|
||||
*/
|
||||
class File extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'files';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
||||
+7
-7
@@ -54,13 +54,13 @@ class User extends AbstractModel implements
|
||||
return $this->hasMany(PasswordReset::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function employers(): belongsToMany {
|
||||
return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_id');
|
||||
}
|
||||
// public function employers(): belongsToMany {
|
||||
// return $this->belongsToMany(CompanyModule::class, (new CompanyEmployee())->getTable(), 'user_id', 'module_id');
|
||||
// }
|
||||
|
||||
public function tweets(): hasMany {
|
||||
return $this->hasMany(Order::class, 'user_id', 'id');
|
||||
}
|
||||
// public function tweets(): hasMany {
|
||||
// return $this->hasMany(Order::class, 'user_id', 'id');
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@@ -68,6 +68,6 @@ class User extends AbstractModel implements
|
||||
*/
|
||||
public function company(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Company::class, 'company_employee');
|
||||
return $this->belongsToMany(Company::class, 'company_employee', 'user_id', 'company_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"fideloper/proxy": "^4.2",
|
||||
"fruitcake/laravel-cors": "^1.0",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "^7.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
"spatie/laravel-activitylog": "^3.14",
|
||||
|
||||
Generated
+71
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f218c85b341310aa83abf66de10c33ab",
|
||||
"content-hash": "2cb6e433182b50af0d18e09467a05407",
|
||||
"packages": [
|
||||
{
|
||||
"name": "asm89/stack-cors",
|
||||
@@ -699,6 +699,76 @@
|
||||
],
|
||||
"time": "2020-09-30T07:37:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
|
||||
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use GD library based image processing.",
|
||||
"ext-imagick": "to use Imagick based image processing.",
|
||||
"intervention/imagecache": "Caching extension for the Intervention Image library"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Intervention\\Image\\ImageServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Image": "Intervention\\Image\\Facades\\Image"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Intervention\\Image\\": "src/Intervention/Image"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.com",
|
||||
"homepage": "http://olivervogel.com/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling and manipulation library with support for Laravel integration",
|
||||
"homepage": "http://image.intervention.io/",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"laravel",
|
||||
"thumbnail",
|
||||
"watermark"
|
||||
],
|
||||
"time": "2019-11-02T09:15:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v7.28.4",
|
||||
|
||||
@@ -18,6 +18,7 @@ class CreateStatesTable extends Migration
|
||||
$table->bigInteger('country_id')->unsigned()->nullable();
|
||||
$table->foreign('country_id')->references('id')->on('countries')->onDelete('cascade');
|
||||
$table->string('name')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ class CreateDistrictsTable extends Migration
|
||||
$table->foreign('state_id')->references('id')->on('states')->onDelete('cascade');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('postcode')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ class CreateCompaniesTable extends Migration
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('type')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDocumentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('documents', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('owner_id')->nullable();
|
||||
$table->integer('owner_type')->nullable();
|
||||
$table->string('document_type')->nullable();
|
||||
$table->string('reference')->nullable();
|
||||
$table->integer('status')->nullable();
|
||||
$table->bigInteger('approved_by')->unsigned();
|
||||
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade')->nullable();
|
||||
$table->timestamp('issued_date')->nullable();
|
||||
$table->timestamp('expired_date')->nullable();
|
||||
$table->timestamp('approved_date')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('documents');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFilesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('document_id')->unsigned();
|
||||
$table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade');
|
||||
$table->text('file')->nullable();
|
||||
$table->string('file_type')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ class CountriesTableSeeder extends Seeder
|
||||
'name' => 'Malaysia',
|
||||
'short_code' => 'MY',
|
||||
'phone_code' => '60',
|
||||
'status' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]
|
||||
|
||||
@@ -19,7 +19,6 @@ class CurrenciesTableSeeder extends Seeder
|
||||
'name' => 'Ringgit',
|
||||
'short_code' => 'MYR',
|
||||
'symbol' => 'RM',
|
||||
'status' => 1,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]
|
||||
|
||||
+53
@@ -1132,3 +1132,56 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.upload-box {
|
||||
width: 250px;
|
||||
/*margin: auto;*/
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.file-container {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.file-container [type=file] {
|
||||
cursor: inherit;
|
||||
display: block;
|
||||
filter: alpha(opacity=0);
|
||||
min-height: 100%;
|
||||
min-width: 100%;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
text-align: right;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.file-container {
|
||||
text-align: center;
|
||||
border: 1px dashed #d9d9d9;
|
||||
background: #f3f3f4;
|
||||
/*border-radius: 10px;*/
|
||||
/* float: left; */
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
.file-container:hover {
|
||||
border-color: #1AB394;
|
||||
}
|
||||
|
||||
.file-container [type=file] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.upload-img {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.upload-img img {
|
||||
width: 100%;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-top: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -80,7 +80,6 @@
|
||||
successHandler(response){
|
||||
localStorage.setItem('user-token', response.payload.access_token);
|
||||
this.$store.dispatch('userAuthentication', {access_token: response.payload.access_token});
|
||||
|
||||
this.error = '';
|
||||
this.$store.dispatch('toggleSection', {name: 'loginSuccess', status: true})
|
||||
setTimeout(function(){
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
this.submit((this.route('api.account.registration')), 'post', 'registrationSection', true, true)
|
||||
},
|
||||
errorHandler(){
|
||||
console.log('nononon');
|
||||
|
||||
},
|
||||
successHandler(){
|
||||
console.log('yess');
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div class="row p-t-25 text-left">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="b-l b-success p-l-15 m-b-15" style="border-left-width: 3px;">
|
||||
<h6 class="bold all-caps no-margin text-success">Registration Step 2</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<validation-wrapper-component :validator="$v.parameters.type">
|
||||
<label class="muted">Type</label>
|
||||
<select class="form-control" v-model="parameters.type">
|
||||
<option value="1">Public Company</option>
|
||||
<option value="2">Personal Company</option>
|
||||
</select>
|
||||
</validation-wrapper-component>
|
||||
<validation-wrapper-component :validator="$v.parameters.file">
|
||||
<label class="muted">File</label>
|
||||
<div class="upload-box">
|
||||
<div class="file-container">
|
||||
<i class="fa fa-cloud-upload"></i>
|
||||
<input type='file'
|
||||
@change="onChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="upload-img">
|
||||
<div v-if="preview" v-for="(img, $index) in preview" :key="$index">
|
||||
<img class='img-responsive' alt='' :src="img"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</validation-wrapper-component>
|
||||
<validation-wrapper-component :validator="$v.parameters.document_reference">
|
||||
<label class="muted">Refrence</label>
|
||||
<input class="form-control" name="name" v-model="parameters.document_reference">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col text-right">
|
||||
<button type="button" class="btn btn-success" @click="submitForm()">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { required, email, sameAs, numeric } from "vuelidate/lib/validators";
|
||||
export default {
|
||||
props: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
parameters : {
|
||||
type: '',
|
||||
file: [],
|
||||
document_reference: ''
|
||||
},
|
||||
preview: []
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
type: { required },
|
||||
file: { required },
|
||||
document_reference: { required },
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
onChange(e) {
|
||||
let vm = this;
|
||||
let files = e.target.files;
|
||||
|
||||
vm.preview = [];
|
||||
Array.from(files).forEach(file => {
|
||||
vm.preview.push(URL.createObjectURL(file));
|
||||
});
|
||||
|
||||
vm.imageBase64(e.target.files).then(data => {
|
||||
vm.parameters.file = data;
|
||||
});
|
||||
},
|
||||
imageBase64(imgs) {
|
||||
let num = 1;
|
||||
let base = [];
|
||||
let count = imgs.length;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
Array.from(imgs).forEach(file => {
|
||||
let reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
base.push(reader.result);
|
||||
if (num >= count) {
|
||||
resolve(base);
|
||||
}
|
||||
num++;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
})
|
||||
});
|
||||
},
|
||||
submitForm(){
|
||||
this.submit((this.route('api.account.registration-step-2')), 'post', 'RegistrationSectionStep2', true, true)
|
||||
},
|
||||
errorHandler(){
|
||||
|
||||
},
|
||||
successHandler(){
|
||||
this.crudSuccess();
|
||||
EventBus.$emit('updateAddress')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,4 @@
|
||||
@extends('layouts.base_login')
|
||||
@section('inner_content')
|
||||
<registration-step-2-form-component ref="registration-step-2" :section="'RegistrationSectionStep2'"></registration-step-2-form-component>
|
||||
@endSection
|
||||
+4
-1
@@ -7,7 +7,7 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
|
||||
Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () {
|
||||
|
||||
Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () {
|
||||
Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
|
||||
Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
|
||||
});
|
||||
|
||||
// Route::group(['prefix' => 'password', 'as' => 'password.'], function () {
|
||||
@@ -15,7 +15,10 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
|
||||
// Route::post('/reset', 'ResetPasswordController@reset')->name('reset');
|
||||
// });
|
||||
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'valid.token'], function () {
|
||||
Route::post('/registration-setp-2', 'RegistrationStep2Controller@create')->name('registration-step-2');
|
||||
});
|
||||
|
||||
Route::post('/registration', 'CreateUserController@create')->name('registration');
|
||||
|
||||
+7
-2
@@ -20,12 +20,17 @@ Route::get('', function () {
|
||||
|
||||
Route::get('account/registration', function () {
|
||||
return view('pages.accounts.registration');
|
||||
})->name('login');
|
||||
})->name('registration');
|
||||
|
||||
Route::get('account/registration-step-2', function () {
|
||||
return view('pages.accounts.registration_step_2');
|
||||
})->name('registration-step-2');
|
||||
|
||||
|
||||
Route::get('account/password/reset/{token}', function ($token){
|
||||
return view('pages.accounts.authentication.reset_password',['token' => $token]);
|
||||
})->name('account.password.reset');
|
||||
|
||||
route::get('dashboard/', function (){
|
||||
return 'dashboard page here';
|
||||
return redirect()->route('registration-step-2');
|
||||
})->name('dashboard');
|
||||
|
||||
Reference in New Issue
Block a user