User Registration Step 2 Logic Class

Update Company Service Class
Create Documents Service Class
Create File Service Class
Base64 File Convert Service Class
File Upload Storage Service Class
This commit is contained in:
CheeSiong
2020-11-05 14:51:56 +08:00
parent 2bf5de8f3e
commit a2381e44a7
33 changed files with 1025 additions and 40 deletions
+1
View File
@@ -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());
@@ -0,0 +1,158 @@
<?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) {
dd($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();
}
}
@@ -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' => ''
];
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 DocumentType {
public const COMPANY_PUBLIC_SMS_REGISTER = 'COMPANY_PUBLIC_SMS_REGISTER';
public const COMPANY_PERSONAL_IC = 'COMPANY_PERSONAL_IC';
}
@@ -1,8 +0,0 @@
<?php
namespace App\Classes\ValueObjects\Constants;
final class DocumentTypes {
public const COMPANY_PUBLIC_SMS_REGISTER = 1;
public const COMPANY_PERSONAL_IC = 2;
}
@@ -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;
}
@@ -2,6 +2,6 @@
namespace App\Classes\ValueObjects\Constants;
final class DocumentTypes {
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\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 -1
View File
@@ -1,6 +1,6 @@
<?php
namespace App;
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Content
* Class File
* @package App\Models
* @version August 4, 2020, 4:36 am
*
@@ -14,11 +14,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property text file
* @property int file_type_id
*/
class Content extends AbstractModel
class File extends AbstractModel
{
use SoftDeletes;
protected $table = 'contacts';
protected $table = 'files';
protected $dates = ['deleted_at'];
}
+7 -7
View File
@@ -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');
}
}
+1
View File
@@ -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
View File
@@ -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",
@@ -19,6 +19,7 @@ class CreateCompaniesTable extends Migration
$table->string('reference')->nullable();
$table->integer('type')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
@@ -17,11 +17,11 @@ class CreateDocumentsTable extends Migration
$table->id();
$table->integer('owner_id')->nullable();
$table->integer('owner_type')->nullable();
$table->integer('document_type')->nullable();
$table->integer('status')->nullable();
$table->string('document_type')->nullable();
$table->string('reference')->nullable();
$table->integer('status')->nullable();
$table->bigInteger('approved_by')->unsigned();
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade');
$table->foreign('approved_by')->references('id')->on('users')->onDelete('cascade')->nullable();
$table->timestamp('issued_date')->nullable();
$table->timestamp('expired_date')->nullable();
$table->timestamp('approved_date')->nullable();
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContentsTable extends Migration
class CreateFilesTable extends Migration
{
/**
* Run the migrations.
@@ -13,12 +13,12 @@ class CreateContentsTable extends Migration
*/
public function up()
{
Schema::create('contents', function (Blueprint $table) {
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->bigInteger('document_id')->unsigned();
$table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade');
$table->text('file')->nullable();
$table->integer('file_type_id')->nullable();
$table->string('file_type')->nullable();
$table->timestamps();
$table->softDeletes();
});
@@ -31,6 +31,6 @@ class CreateContentsTable extends Migration
*/
public function down()
{
Schema::dropIfExists('contents');
Schema::dropIfExists('files');
}
}
@@ -79,12 +79,14 @@
methods:{
successHandler(response){
localStorage.setItem('user-token', response.payload.access_token);
console.log(response.payload.access_token);
this.$store.dispatch('userAuthentication', {access_token: response.payload.access_token});
this.error = '';
this.$store.dispatch('toggleSection', {name: 'loginSuccess', status: true})
setTimeout(function(){
window.location.href = response.payload.redirect_url;
// window.location.href = response.payload.redirect_url;
}, 2000);
},
errorHandler(error){
+7 -1
View File
@@ -7,9 +7,11 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
Route::group(['prefix' => 'authentication', 'as' => 'authentication.'], function () {
Route::group(['prefix' => 'login', 'as' => 'authenticate.'], function () {
Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
Route::post('/attempt', 'UserAuthenticationController@authenticate')->name('attempt');
});
// Route::group(['prefix' => 'password', 'as' => 'password.'], function () {
// Route::post('/forget', 'GeneratePasswordResetController@generate')->name('forget');
// Route::post('/reset', 'ResetPasswordController@reset')->name('reset');
@@ -17,6 +19,10 @@ Route::group(['prefix' => 'account', 'namespace' => 'Accounts', 'as' => 'account
});
Route::group(['middleware' => 'valid.token'], function () {
Route::post('/registration-setp-2', 'UpdateUserController@update')->name('registration');
});
Route::post('/registration', 'CreateUserController@create')->name('registration');