mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
233 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c3dead6b7 | |||
| 058ba592bf | |||
| d950ee3d68 | |||
| 575379adc0 | |||
| da6ec00dbd | |||
| 412dbd64d5 | |||
| 496df549f6 | |||
| 97eaefa45a | |||
| 68c9e0451a | |||
| 671c7a54fb | |||
| 2a28183426 | |||
| 0ebea79750 | |||
| a701242646 | |||
| 4bdeae997d | |||
| 36809f34cc | |||
| 032171bb18 | |||
| d41bd3db39 | |||
| 56bba0eaaf | |||
| af8444e0d9 | |||
| b2a7d1f73d | |||
| 9d2ff3fafa | |||
| 487d07e28c | |||
| 4176e09ea3 | |||
| c44bf46a42 | |||
| e687dd2b9a | |||
| 59951c4efd | |||
| c00a4712a0 | |||
| 1bb07e9402 | |||
| 683bdec1f7 | |||
| ee53a9438a | |||
| 2e2087f16e | |||
| 998b0b4da5 | |||
| dcf5c2e455 | |||
| 156b1dee07 | |||
| 544d7907c3 | |||
| 5b77f7baa6 | |||
| b33016aac4 | |||
| 2788e349ae | |||
| 04af87f640 | |||
| 5b190d5334 | |||
| 8f32769656 | |||
| 0e79bbfd6a | |||
| 3a411e8b9a | |||
| bffe438455 | |||
| d17beda04b | |||
| 7acc6932b5 | |||
| 2d175f4acc | |||
| 31905e56be | |||
| 6508155aea | |||
| 760f8684ea | |||
| 979b8b2ef9 | |||
| 9a0073e906 | |||
| 976e54bb4c | |||
| 87226377be | |||
| 674fd84fa0 | |||
| da1ed10740 | |||
| eb73d20b00 | |||
| 782aed06e4 | |||
| 158fa2eefe | |||
| fa4cfc0d75 | |||
| f87bcff930 | |||
| e774962c44 | |||
| f5482a29e4 | |||
| 0a14a64fbb | |||
| ee5051fc26 | |||
| 034c93091a | |||
| 8b184313cb | |||
| c2b097e6d1 | |||
| b0195a9640 | |||
| 38d69434fa | |||
| 1b559f91a2 | |||
| 05a21af5a6 | |||
| 3e7fbdbafc | |||
| 527eca50fe | |||
| d010a8f8c7 | |||
| 7bc2ca512a | |||
| b76e0ebeef | |||
| f595c43f2c | |||
| 5584d22376 | |||
| 42b6140df7 | |||
| 619fc25605 | |||
| 8c24c86c77 | |||
| 822046cc69 | |||
| d708b8b540 | |||
| 553d2c44aa | |||
| 0f7f5f7ab9 | |||
| a5c1ae14b7 | |||
| 8f5aa0a861 | |||
| 1bed7f1cc9 | |||
| 0a16e40a23 | |||
| 5c24b6f81e | |||
| b81f3e50ad | |||
| 3f1a8a6d12 | |||
| 2240c1723d | |||
| 5d07598c5e | |||
| c493b3786c | |||
| e4f60a7bff | |||
| fe000b7a6f | |||
| 707ef9d9f3 | |||
| b5abb04c63 | |||
| 1dbad7d6e5 | |||
| 25417ba5be | |||
| fe67cc6c5b | |||
| 90b85c0df1 | |||
| 0cdff7c544 | |||
| 42561a7c56 | |||
| 99f4699260 | |||
| 0ea52048e1 | |||
| a47bb95e50 | |||
| 431aed18d3 | |||
| 6ab289057b | |||
| c55a8e7af9 | |||
| 60fbe77829 | |||
| fbf097eb62 | |||
| 30c2673fdf | |||
| fd3709e103 | |||
| 08473d85ab | |||
| 489974ca5a | |||
| 6a6a0f0ee7 | |||
| 402f64364b | |||
| a3bff9d079 | |||
| 2a7a448059 | |||
| 7d855064da | |||
| efc0a3b94e | |||
| 01654ee0d3 | |||
| 23c2f92e6d | |||
| 3945c47f52 | |||
| 51ab6ce48b | |||
| ca8140a1ba | |||
| a84580c1dd | |||
| 63b212a66c | |||
| 7979d89997 | |||
| bc603fc125 | |||
| b55fd49830 | |||
| 60ceac645f | |||
| 90c599049b | |||
| f538fb7f2f | |||
| a45105f5ae | |||
| 2f1a8ee648 | |||
| aacf4ea53d | |||
| 1fa2b60871 | |||
| 203dc0c230 | |||
| fcc4da1a56 | |||
| c5a49bbc44 | |||
| f8131b3a1e | |||
| 336cc0b37f | |||
| 42f096b09c | |||
| 614167cac5 | |||
| e5421f8810 | |||
| 8dc84baee0 | |||
| a413533975 | |||
| 0a98f8a8c6 | |||
| aceed5f754 | |||
| 761d191c1d | |||
| d769be137e | |||
| d6a5dd56c6 | |||
| f279d39ddb | |||
| 2e1e8875b4 | |||
| c30c5a36f2 | |||
| 7d3901ee48 | |||
| 463398945f | |||
| d619862e63 | |||
| 9665a0e242 | |||
| 7ed6c11f37 | |||
| 3eaee0d122 | |||
| b7816873fe | |||
| 8809caa046 | |||
| b8b6910a45 | |||
| 64bfbac4f7 | |||
| a5b7e79964 | |||
| 03c9bec256 | |||
| 06134e006c | |||
| 7563b455ba | |||
| 26edb3bebd | |||
| 55e1a6ad02 | |||
| 381425c6bc | |||
| 09ab95faf8 | |||
| 8bb6f0317a | |||
| fe95db2605 | |||
| 02640e6ae8 | |||
| 104dd19a6f | |||
| 89117c0706 | |||
| bc650b0816 | |||
| a6a239c489 | |||
| 45b78465da | |||
| 71edeca994 | |||
| cd229c6a8f | |||
| ebc3e588ca | |||
| 80471acc5b | |||
| ea08774111 | |||
| 4a1f05e62a | |||
| 840fb86192 | |||
| 7a171685f6 | |||
| 096e039ffb | |||
| 2319393758 | |||
| 85ba9d66d5 | |||
| 626dff6137 | |||
| 99efce22db | |||
| 4a9e89c752 | |||
| 39e3398f8e | |||
| 7db77d619b | |||
| 8f390311af | |||
| 6502957021 | |||
| d6ddf6d607 | |||
| b368b1c0d1 | |||
| a2ef3ed1b1 | |||
| e1b712ad10 | |||
| ddbfc5fdfd | |||
| 1cdd511f67 | |||
| f7d0fe117e | |||
| 4dede50156 | |||
| 0d555eedc9 | |||
| 7f73ec14a5 | |||
| 408397e20e | |||
| ef37f1ebbe | |||
| 914e9a6f0f | |||
| 525e7a5dd1 | |||
| a3cad7816c | |||
| 2100c4a14a | |||
| 0d090b4eaf | |||
| 73801a5acd | |||
| 2c0eeab84e | |||
| 40c4a39927 | |||
| 866df52e52 | |||
| b34d909a09 | |||
| 26b3e968e9 | |||
| 7b127b2cba | |||
| 7488313a0e | |||
| 7589b5c553 | |||
| d8391fe479 | |||
| c01e8d6eb2 | |||
| 5aad5f1729 | |||
| 485a6e2e82 |
+2
-4
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,8 +56,6 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,8 +2,6 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
@@ -27,6 +25,3 @@ package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
storage/framework/laravel-excel/*
|
||||
.vapor/
|
||||
.env.production
|
||||
.env.staging
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
image: php:7.4
|
||||
stages:
|
||||
- deploy
|
||||
|
||||
#jobs
|
||||
#deploy
|
||||
deploy:
|
||||
stage: deploy
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
# Install docker
|
||||
- apt-get update
|
||||
- apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release software-properties-common
|
||||
- curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
|
||||
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
|
||||
- apt-get update
|
||||
- apt-get install -y docker-ce docker-ce-cli containerd.io
|
||||
- service docker start
|
||||
|
||||
# Install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
script:
|
||||
- composer install
|
||||
- vendor/bin/vapor deploy production --message="$CI_COMMIT_MESSAGE"
|
||||
only:
|
||||
- test
|
||||
|
||||
|
||||
@@ -1,39 +1,62 @@
|
||||
## Shipping portal documentation
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||
|
||||
simple documentation on how to install, run, test, commit and deploy application
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## creating and running unit tests
|
||||
## About Laravel
|
||||
|
||||
Required Tools
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- Chromium Driver / selenium
|
||||
- add running and setting selenium on all OS if possible
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Required Packages :
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
- laravel/legacy-factories
|
||||
## Learning Laravel
|
||||
|
||||
- codeception/codeception
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
Or Simply Run
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
``Composer install``
|
||||
## Laravel Sponsors
|
||||
|
||||
To create a unit test
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
``php artisan make test: Test Example --unit``
|
||||
### Premium Partners
|
||||
|
||||
Running the tests :
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
|
||||
Running a single Test
|
||||
## Contributing
|
||||
|
||||
`` php artisan test --filter Example``
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
Running Unit tests -
|
||||
## Code of Conduct
|
||||
|
||||
`` php artisan test ``
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
Running Codeception tests -
|
||||
## Security Vulnerabilities
|
||||
|
||||
``vendor/bin/codecept run``
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Exceptions;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
final class ConnectionErrorException extends ServiceApiException {
|
||||
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
|
||||
Log::error($message. ": ". $exceptionMessage);
|
||||
if($payload){
|
||||
Log::error('Payload: '.$payload);
|
||||
}
|
||||
if($exceptionTrace){
|
||||
Log::error($exceptionTrace);
|
||||
}
|
||||
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
|
||||
HttpStatus::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Abstracts;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\ErrorException;
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\ValueObjects\Constants\Notifications;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use ErrorException as GeneralExceptions;
|
||||
use TypeError;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
abstract class Abstract2ControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function notification(): array;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getNotificationTitle():string {
|
||||
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getNotificationMessage():string {
|
||||
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return BinaryFileResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
abstract protected function logic(Request $request) : BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return BinaryFileResponse
|
||||
*/
|
||||
public function execute(Request $request) : BinaryFileResponse {
|
||||
|
||||
try {
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
$response = $this->logic($request);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $response;
|
||||
|
||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||
abort(404, $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $data
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function response(?array $data = []) : JsonResponse {
|
||||
|
||||
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
|
||||
$this->getNotificationMessage(),
|
||||
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param JsonResource $resource
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function resourceResponse(JsonResource $resource){
|
||||
return $this->response(['data' => $resource]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ResourceCollection $collection
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function collectionResponse(ResourceCollection $collection){
|
||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
||||
abstract class AbstractRule
|
||||
{
|
||||
|
||||
abstract protected function authorized(): bool;
|
||||
abstract protected function authorized($object): bool;
|
||||
|
||||
abstract protected function validators($object): bool;
|
||||
|
||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
||||
*/
|
||||
public function passes(?DataTransferObject $object = null): bool {
|
||||
try {
|
||||
if(!$this->authorized()){
|
||||
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||
if(!$this->authorized($object)){
|
||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||
}
|
||||
|
||||
$this->validators($object);
|
||||
@@ -36,11 +36,11 @@ abstract class AbstractRule
|
||||
return true;
|
||||
|
||||
} catch(AccessForbiddenException $exception){
|
||||
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||
} catch(\Exception $exception){
|
||||
throw new RequestValidationException($exception->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BillNo implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('bill_no', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedAfterOrEqual implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$table = $builder->getModel()->getTable();
|
||||
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
||||
return $builder->where("{$table}.created_at", '>=', $startDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CreatedBeforeOrEqual implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$table = $builder->getModel()->getTable();
|
||||
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
||||
return $builder->where("{$table}.created_at", '<=', $endDate);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||
$query->where('type', $value)->whereIn('status', [0,1,2,3]);
|
||||
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
||||
})->whereHas('containers', function ($query){
|
||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||
});
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class HasQuestionnaireGroupIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
|
||||
$query->whereIn('group', $value);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class OwnerId implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_id', $value);
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->where("{$table}.owner_id", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class OwnerType implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_type', $value);
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->where("{$table}.owner_type", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PaymentMethodNotIn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereNotIn('payment_method', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ShortUrl implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('short_url', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ class StatusIn implements Filter
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereIn('status', $value);
|
||||
$table = $builder->getModel()->getTable();
|
||||
return $builder->whereIn("{$table}.status", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithAgingColumn implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
$today = Carbon::now();
|
||||
return $builder->select('packing_lists.*')
|
||||
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
||||
->addSelect(DB::raw("CASE
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
||||
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
||||
ELSE 4
|
||||
END AS due_date_number"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class WithOrderReferenceLike implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
||||
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
||||
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
||||
->join('orders', function ($join) use ($value) {
|
||||
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
||||
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
||||
})
|
||||
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,11 @@ class Helper
|
||||
return array_slice(get_class_methods($className), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param $log
|
||||
* @return none
|
||||
*/
|
||||
static function debugLoggerForPerfexCRM($log){
|
||||
if($log){
|
||||
static function debugLogger($log){
|
||||
if($log && isset($log['message'])){
|
||||
$message = $log['message'];
|
||||
$substring = 'No data were found';
|
||||
if (isset($message)) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -10,6 +12,8 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
@@ -18,37 +22,51 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob;
|
||||
|
||||
/** @var */
|
||||
private $transaction;
|
||||
|
||||
/** @var bool|null */
|
||||
private $shouldCreateInvoice;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRM constructor.
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRMInvoice $nextJob
|
||||
* @param $transaction
|
||||
* @param Transaction $transaction
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
||||
{
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob = $nextJob;
|
||||
$this->transaction = $transaction;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
//To use invoice as a reference to decide whether more tasks should be created
|
||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
||||
|
||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
if($this->nextJob != null && $this->transaction != null){
|
||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$result->projectId,
|
||||
$this->transaction,
|
||||
true
|
||||
);
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob */
|
||||
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
|
||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
||||
}
|
||||
}
|
||||
|
||||
private function getInvoiceIdOrCreateInvoice(){
|
||||
if($this->transaction != null){
|
||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$this->transaction
|
||||
);
|
||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
||||
return $invoiceId;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,16 +11,14 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
@@ -32,7 +30,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||
{
|
||||
@@ -49,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = 0;
|
||||
$invoiceStatus = 0;
|
||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $transaction->owner->bill_no: '.$transaction->owner->bill_no));
|
||||
Log::error('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
|
||||
if(is_null($invoice)){
|
||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||
@@ -57,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
$invoiceId = $result->payload['id'];
|
||||
} else {
|
||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
Helper::debugLogger('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -66,7 +64,6 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
|
||||
//update invoice
|
||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||
}
|
||||
|
||||
@@ -27,27 +27,22 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRM */
|
||||
private $nextJob1;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob2;
|
||||
/** @var bool|null */
|
||||
private $shouldCreateInvoice;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param $packingList
|
||||
* @param $transaction
|
||||
* @param Transaction $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRM $nextJob1
|
||||
* @param UpdatePerfexCRMInvoice $nextJob2
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
*/
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||
{
|
||||
$this->packingList = $packingList;
|
||||
$this->transaction = $transaction;
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob1 = $nextJob1;
|
||||
$this->nextJob2 = $nextJob2;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
@@ -69,9 +64,7 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
|
||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||
$this->updatePerfexCRMObject->setTasks($result);
|
||||
/** @var UpdatePerfexCRM $nextJob1 */
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
||||
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
||||
}
|
||||
|
||||
function replacePlaceholders($template, $data, $prefix = '')
|
||||
|
||||
@@ -28,7 +28,8 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
|
||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
||||
|
||||
use App\Classes\Modules\Accounts\Processors\RegisterOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\User;
|
||||
@@ -36,6 +37,7 @@ use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateCustomerLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -87,6 +89,12 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
/** @var CreatePerfexCRMLeadProcessor */
|
||||
private $createPerfexCRMLeadProcessor;
|
||||
|
||||
/** @var RegisterOnExchangeProcessor */
|
||||
private $registerOnExchangeProcessor;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* CreateCustomerLogic constructor.
|
||||
* @param CreateUserProcessor $createUserProcessor
|
||||
@@ -101,8 +109,10 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
||||
* @param RegisterOnExchangeProcessor $registerOnExchangeProcessor
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, RegisterOnExchangeProcessor $registerOnExchangeProcessor, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
{
|
||||
$this->createUserProcessor = $createUserProcessor;
|
||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||
@@ -116,6 +126,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
||||
$this->registerOnExchangeProcessor = $registerOnExchangeProcessor;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +165,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
$this->assignEmployeeProcessor->execute($Object);
|
||||
|
||||
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
// $this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||
|
||||
if(config('perfexcrm.is_enabled') == 'true'){
|
||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
||||
@@ -169,6 +181,19 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
||||
|
||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||
|
||||
$exchangeCompanyId = null;
|
||||
if ($request->input('exchange_company_id')) {
|
||||
$exchangeCompanyId = $request->input('exchange_company_id');
|
||||
} else {
|
||||
// register account on exchange portal if this registration not coming from exchange
|
||||
$exchangeCompanyId = $this->registerOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
if ($exchangeCompanyId) {
|
||||
// create exchange company connection
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $exchangeCompanyId);
|
||||
}
|
||||
|
||||
return $this->response($this->authenticationProcessor->execute($request));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationTokenWithExchangeBookingId;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoginThroughExchangeLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Authentication',
|
||||
'message' => 'You have successfully logged in to your account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var AuthenticationProcessor */
|
||||
private $authenticationProcessor;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var GeneratesAuthenticationTokenWithExchangeBookingId */
|
||||
private $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
|
||||
|
||||
/**
|
||||
* LoginThroughExchangeLogic constructor.
|
||||
* @param AuthenticationProcessor $authenticationProcessor
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId
|
||||
*/
|
||||
public function __construct(GeneratesAuthenticationToken $generatesAuthenticationToken, GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId)
|
||||
{
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->generatesAuthenticationTokenWithExchangeBookingId = $generatesAuthenticationTokenWithExchangeBookingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
$token = explode('.', $request->input("exchangeToken"))[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$exchangeCompanyId = $exchangeUser['company_id'];
|
||||
$connection = ExchangeCompanyConnection::where("exchange_company_id", $exchangeCompanyId)->first();
|
||||
if (!$connection) {
|
||||
throw new AccessUnauthorisedException('These credentials do not match our records.');
|
||||
}
|
||||
$companyModule = $connection->companyModule;
|
||||
$user = $companyModule->employees->last();
|
||||
|
||||
$exchangeBookingId = null;
|
||||
if (isset($exchangeUser['booking_id']) && $exchangeUser['booking_id']) {
|
||||
$exchangeBookingId = $exchangeUser['booking_id'];
|
||||
$token = $this->generatesAuthenticationTokenWithExchangeBookingId->execute($user, $exchangeBookingId);
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('dashboard') . "?createOrder=true"]);
|
||||
} else {
|
||||
$token = $this->generatesAuthenticationToken->execute($user);
|
||||
$order = Order::where('id', $request->input("orderId"))->first();
|
||||
|
||||
return $this->response(['access_token' => $token, 'redirect_url' => route('order.show' , $order->reference)]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RegisterOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = 'https://exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = 'http://127.0.0.1:8000/api/v1/account/registration/registration';
|
||||
} else {
|
||||
$url = 'https://dev.exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$formParams = $request->toArray();
|
||||
$formParams['shipping_company_module_id'] = $companyModuleId;
|
||||
$response = $client->request('POST', $url, ['form_params' => $formParams]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
$payload = $contents['payload'];
|
||||
$token = explode('.', $payload['access_token'])[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
|
||||
return $exchangeUser['company_id'];
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Accounts\Services;
|
||||
|
||||
use App\Classes\Exceptions\InternalServerErrorException;
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Models\Company;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\JWT;
|
||||
|
||||
class GeneratesAuthenticationTokenWithExchangeBookingId {
|
||||
|
||||
/** @var JWT */
|
||||
private $builder;
|
||||
|
||||
|
||||
/**
|
||||
* GeneratesAuthenticationTokenWithExchangeBookingId constructor.
|
||||
* @param JWT $builder
|
||||
*/
|
||||
public function __construct(JWT $builder) {
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param bool $rememberUser
|
||||
* @return string
|
||||
*/
|
||||
public function execute(User $user, $bookingId): string {
|
||||
|
||||
$this->builder->manager()->setBlacklistEnabled(false);
|
||||
|
||||
// generate token for the customer
|
||||
$this->builder->factory()->setTTL(Carbon::now()->addDay()->timestamp);
|
||||
|
||||
// set the claim based on the object
|
||||
$this->setTokenClaims($user, $bookingId);
|
||||
|
||||
return $this->builder->fromUser($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
private function setTokenClaims(User $user, $bookingId): void {
|
||||
|
||||
$claims = [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
'status' => $user->status
|
||||
];
|
||||
|
||||
if($user->type === RoleTypes::USER) {
|
||||
|
||||
/** @var Company $companyModule */
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$claims = array_merge($claims, [
|
||||
'company_id' => $companyModule->company_id,
|
||||
'company_module_id' => $companyModule->id,
|
||||
'company_module_type' => $companyModule->type,
|
||||
'company_name' => $companyModule->name,
|
||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
||||
'exchange_booking_id' => $bookingId
|
||||
]);
|
||||
}
|
||||
|
||||
$this->builder->factory()->customClaims(['user' => $claims]);
|
||||
|
||||
|
||||
$this->builder->factory()->buildClaimsCollection();
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
|
||||
return $this->passwordResetTokenExists->execute($object->getToken());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,19 +68,19 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -47,4 +47,4 @@ class CanCreateBank extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanDeleteBank extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -34,4 +34,4 @@ class CanListBanks extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -51,4 +51,4 @@ class CanUpdateBank extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\Modules\Billplzs\Processors\CallbackBillplzProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
@@ -46,6 +47,9 @@ class CallbackBillplzLogic
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var CallbackBillplzProcessor */
|
||||
private $callbackBillplzProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -54,8 +58,9 @@ class CallbackBillplzLogic
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
* @param CallbackBillplzProcessor $callbackBillplzProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, CallbackBillplzProcessor $callbackBillplzProcessor)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -64,6 +69,7 @@ class CallbackBillplzLogic
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,41 +112,7 @@ class CallbackBillplzLogic
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
|
||||
// check if is wallet top up
|
||||
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
}
|
||||
|
||||
// group payment
|
||||
if ($transaction->type == TransactionType::GROUP_PAYMENT && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
||||
$group = Group::where('reference', $billplzXSignatureObject->getBillPlzId())->first();
|
||||
|
||||
foreach($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if(($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->callbackBillplzProcessor->execute($transaction, $status);
|
||||
|
||||
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Billplzs\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Wallet;
|
||||
use App\Models\Group;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
|
||||
class CallbackBillplzProcessor
|
||||
{
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CreateUserProcessor constructor.
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
*/
|
||||
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
{
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute($transaction, $status)
|
||||
{
|
||||
$invoice = $transaction->owner;
|
||||
$packingList = $invoice->owner;
|
||||
|
||||
$this->updatesTransactionStatus->execute($transaction, $status);
|
||||
|
||||
// check if is wallet top up
|
||||
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||
|
||||
$this->updatesWalletBalance->execute($transaction->owner, $transaction->amount);
|
||||
|
||||
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||
|
||||
// check if is group payment
|
||||
if ($group) {
|
||||
foreach ($group->groupTransactions as $groupTransaction) {
|
||||
$invoice = $groupTransaction->transaction;
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null);
|
||||
}
|
||||
|
||||
$group->status = $status;
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$transaction->owner instanceof Wallet) {
|
||||
$totalPaidAmount = $invoice->transactions->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->sum('amount');
|
||||
|
||||
if (($invoice->amount - $totalPaidAmount) < 0.01) {
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if (app()->environment('production')) {
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class CreatesBillplzBill
|
||||
{
|
||||
@@ -25,7 +26,7 @@ class CreatesBillplzBill
|
||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||
'collection_id' => config('billplz.collection_id'),
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
|
||||
'description' => $description,
|
||||
'amount' => $this->finalizeAmount($amount),
|
||||
'redirect_url' => route('online_payment.redirect'),
|
||||
|
||||
+23
-4
@@ -10,16 +10,18 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
|
||||
use App\Classes\Modules\Companies\Processors\ApproveIdentificationDocumentOnExchangeProcessor;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
|
||||
use App\Classes\Modules\Documents\Services\ApprovesDocument;
|
||||
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
||||
Use App\Classes\Modules\Notifications\Processors\CreateNotificationProcessor;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -55,6 +57,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var CreateNotificationProcessor */
|
||||
private $createNotificationProcessor;
|
||||
|
||||
/** @var ApproveIdentificationDocumentOnExchangeProcessor */
|
||||
private $approveIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
/**
|
||||
* ApproveIdentificationDocumentLogic constructor.
|
||||
* @param CanApproveDocument $canApproveDocument
|
||||
@@ -64,8 +69,9 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param UpdatesOrdersStatus $updatesOrdersStatus
|
||||
* @param CreateNotificationProcessor $createNotificationProcessor
|
||||
* @param ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor)
|
||||
public function __construct(CanApproveDocument $canApproveDocument, ApprovesDocument $approvesDocument, RejectsDocument $rejectsDocument, FetchesDocument $fetchesDocument, UpdatesCompanyStatus $updatesCompanyStatus, UpdatesOrdersStatus $updatesOrdersStatus, CreateNotificationProcessor $createNotificationProcessor, ApproveIdentificationDocumentOnExchangeProcessor $approveIdentificationDocumentOnExchangeProcessor)
|
||||
{
|
||||
$this->canApproveDocument = $canApproveDocument;
|
||||
$this->approvesDocument = $approvesDocument;
|
||||
@@ -74,6 +80,7 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->updatesOrdersStatus = $updatesOrdersStatus;
|
||||
$this->createNotificationProcessor = $createNotificationProcessor;
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor = $approveIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +92,18 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$documentId = $request->route('document_id');
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$company = $companyModule->company;
|
||||
$documentId = $company->documents()->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->where('status', ApprovalStatus::PENDING_VERIFICATION)->first()->id;
|
||||
}
|
||||
|
||||
$status = $request->route('status');
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->fetchesDocument->execute(['id' => $request->route('document_id')]);
|
||||
$document = $this->fetchesDocument->execute(['id' => $documentId]);
|
||||
|
||||
$this->canApproveDocument->passes();
|
||||
|
||||
@@ -111,6 +125,11 @@ class ApproveIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
$orders = $this->updatesOrdersStatus->execute($document->owner, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
// if this request is not calling from exchange portal, then approve the document on exchange portal for this user
|
||||
$companyModule = $document->owner->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->approveIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id, $status);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new DocumentResource($document));
|
||||
|
||||
|
||||
+22
-2
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\CreateIdentificationDocumentOnExchangeProcessor;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\UpdatesCompanyStatus;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
@@ -14,6 +15,7 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Models\Company;
|
||||
use App\Models\Document;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -42,6 +44,9 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
/** @var UpdatesCompanyStatus */
|
||||
private $updatesCompanyStatus;
|
||||
|
||||
/** @var CreateIdentificationDocumentOnExchangeProcessor */
|
||||
private $createIdentificationDocumentOnExchangeProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* CreateIdentificationDocumentLogic constructor.
|
||||
@@ -49,13 +54,15 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFile
|
||||
* @param UpdatesCompanyStatus $updatesCompanyStatus
|
||||
* @param CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus)
|
||||
public function __construct(FetchesCompany $fetchesCompany, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesCompanyStatus $updatesCompanyStatus, CreateIdentificationDocumentOnExchangeProcessor $createIdentificationDocumentOnExchangeProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFile = $createsFile;
|
||||
$this->updatesCompanyStatus = $updatesCompanyStatus;
|
||||
$this->createIdentificationDocumentOnExchangeProcessor = $createIdentificationDocumentOnExchangeProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +73,15 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
if ($request->route('exchange_company_id')) {
|
||||
$companyModule = ExchangeCompanyConnection::where('exchange_company_id', $request->route('exchange_company_id'))->first()->companyModule;
|
||||
$companyId = $companyModule->company_id;
|
||||
} else {
|
||||
$companyId = $request->route('id');
|
||||
}
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||
$company = $this->fetchesCompany->execute(['id' => $companyId]);
|
||||
$object = new DocumentObject($company->type === CompanyType::COMPANY_BUSINESS ?
|
||||
DocumentType::SSM_REGISTRATION : DocumentType::IDENTITY_CARD, $request->input('files'),
|
||||
$request->input('identification_no'), ApprovalStatus::PENDING_VERIFICATION, 'identifications');
|
||||
@@ -78,6 +92,12 @@ class CreateIdentificationDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
$this->updatesCompanyStatus->execute($company, ApprovalStatus::PENDING_VERIFICATION);
|
||||
|
||||
// create identification on exchange if this request not coming from exchange
|
||||
$companyModule = $company->companyModules()->first();
|
||||
if (!$request->route('exchange_company_id') && $companyModule->exchangeCompanyConnection()->first()) {
|
||||
$this->createIdentificationDocumentOnExchangeProcessor->execute($request, $companyModule->id);
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Companies\Processors\LinkExchangeCompanyProcessor;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Connect Exchange with Izyim Account',
|
||||
'message' => 'You have successfully connect your exchange account to Izyim Account'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var LinkExchangeCompanyProcessor */
|
||||
private $linkExchangeCompanyProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* LinkExchangeCompanyLogic constructor.
|
||||
* @param LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor
|
||||
*/
|
||||
public function __construct(LinkExchangeCompanyProcessor $linkExchangeCompanyProcessor)
|
||||
{
|
||||
$this->linkExchangeCompanyProcessor = $linkExchangeCompanyProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function logic(Request $request): JsonResponse {
|
||||
|
||||
return $this->response($this->linkExchangeCompanyProcessor->execute($request));
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ApproveIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId, $status) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/approval/{$status}";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('PUT', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreateIdentificationDocumentOnExchangeProcessor
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return string
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request, $companyModuleId) {
|
||||
if (App::environment(['production'])) {
|
||||
dd("Delete this line before push to production");
|
||||
$url = "https://exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else if (App::environment(['local'])) {
|
||||
$url = "http://127.0.0.1:8000/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
} else {
|
||||
$url = "https://dev.exchange.cief-malaysia.com/api/v1/shipping/company/{$companyModuleId}/identification/create";
|
||||
}
|
||||
try {
|
||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
||||
$token = $request->bearerToken();
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer ' . $token,
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
$formParams = $request->toArray();
|
||||
$response = $client->request('POST', $url, [
|
||||
'headers' => $headers,
|
||||
'form_params' => $formParams
|
||||
]);
|
||||
$body = $response->getBody();
|
||||
$contents = json_decode($body, true);
|
||||
|
||||
return $contents;
|
||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
||||
Log::error($exception->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Processors;
|
||||
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\AuthenticationCredentialsObject;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticatesUser;
|
||||
use App\Classes\Modules\Accounts\Services\AuthenticationRedirect;
|
||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
||||
use App\Classes\Modules\Accounts\Standards\Rules\CanAuthenticateUser;
|
||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkExchangeCompanyProcessor
|
||||
{
|
||||
|
||||
/** @var CanAuthenticateUser */
|
||||
private $canAuthenticateUser;
|
||||
|
||||
/** @var AuthenticatesUser */
|
||||
private $authenticatesUser;
|
||||
|
||||
/** @var GeneratesAuthenticationToken */
|
||||
private $generatesAuthenticationToken;
|
||||
|
||||
/** @var FetchesUser */
|
||||
private $fetchesUser;
|
||||
|
||||
/** @var AuthenticationRedirect */
|
||||
private $authenticationRedirect;
|
||||
|
||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
||||
private $connectCompanyModuleToExchangeCompany;
|
||||
|
||||
/**
|
||||
* AuthenticationProcessor constructor.
|
||||
* @param CanAuthenticateUser $canAuthenticateUser
|
||||
* @param AuthenticatesUser $authenticatesUser
|
||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
||||
* @param FetchesUser $fetchesUser
|
||||
* @param AuthenticationRedirect $authenticationRedirect
|
||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
||||
*/
|
||||
public function __construct(CanAuthenticateUser $canAuthenticateUser, AuthenticatesUser $authenticatesUser, GeneratesAuthenticationToken $generatesAuthenticationToken, FetchesUser $fetchesUser, AuthenticationRedirect $authenticationRedirect, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
||||
{
|
||||
$this->canAuthenticateUser = $canAuthenticateUser;
|
||||
$this->authenticatesUser = $authenticatesUser;
|
||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
||||
$this->fetchesUser = $fetchesUser;
|
||||
$this->authenticationRedirect = $authenticationRedirect;
|
||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function execute(Request $request): array {
|
||||
|
||||
$object = new AuthenticationCredentialsObject($request->input('email'), $request->input('password'));
|
||||
|
||||
$this->canAuthenticateUser->passes($object);
|
||||
|
||||
$this->authenticatesUser->execute($object);
|
||||
|
||||
$user = $this->fetchesUser->execute(['email' => $object->getEmail()]);
|
||||
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $request->route('exchange_company_id'));
|
||||
|
||||
return ['shipping_company_module_id' => $companyModule->id];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Companies\Services;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\ExchangeCompanyConnection;
|
||||
|
||||
class ConnectCompanyModuleToExchangeCompany extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param Company $company
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, $exchangeCompanyId)
|
||||
{
|
||||
$model = new ExchangeCompanyConnection();
|
||||
$model->company_module_id = $companyModule->id;
|
||||
$model->exchange_company_id = $exchangeCompanyId;
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -51,4 +51,4 @@ class CanAssignEmployee extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -48,4 +48,4 @@ class CanCreateCompany extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanFetchCompany extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanListCompanies extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -48,4 +48,4 @@ class CanUpdateCompany extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -51,4 +51,4 @@ class CanCreateContact extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -48,4 +48,4 @@ class CanCreateCurrency extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -36,4 +36,4 @@ class CanDeleteCurrency extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -37,4 +37,4 @@ class CanFetchCurrency extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
@@ -38,4 +38,4 @@ class CanListCurrency extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -51,4 +51,4 @@ class CanUpdateCurrency extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class CanCreateRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
if (!\Auth::user()->can('add currency_rate')) {
|
||||
@@ -52,4 +52,4 @@ class CanCreateRate extends AbstractRule
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanDeleteRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
@@ -42,4 +42,4 @@ class CanDeleteRate extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -40,4 +40,4 @@ class CanFetchRate extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListRates extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
@@ -42,4 +42,4 @@ class CanListRates extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanUpdateRate extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
|
||||
@@ -55,4 +55,4 @@ class CanUpdateRate extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,9 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -62,11 +58,6 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,12 +32,12 @@ class UploadDocumentForHelpMenuProcessor
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param $filesUpload
|
||||
* @param QAUserAnswerSelected qaUserAnswerSelected
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Request $request, QAUserAnswerSelected $qaUserAnswerSelected) {
|
||||
$object = new DocumentObject("HELP_MENU", $request->input('files'),
|
||||
public function execute($filesUpload, QAUserAnswerSelected $qaUserAnswerSelected) {
|
||||
$object = new DocumentObject("HELP_MENU", $filesUpload,
|
||||
'123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded
|
||||
|
||||
/** @var Document $document */
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ApprovesDocument extends AbstractUpdateRecord
|
||||
@@ -17,8 +18,19 @@ class ApprovesDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::APPROVED;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approver = $user->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace App\Classes\Modules\Documents\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RejectsDocument extends AbstractUpdateRecord
|
||||
{
|
||||
@@ -17,8 +20,19 @@ class RejectsDocument extends AbstractUpdateRecord
|
||||
*/
|
||||
public function execute(Document $model)
|
||||
{
|
||||
$user = Auth()->user();
|
||||
// if auth user is null, then this services is calling from exchange
|
||||
if (!$user) {
|
||||
$token = explode('.', request()->bearerToken())[1];
|
||||
$decodedToken = base64_decode($token);
|
||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
||||
$user = User::where('email', $exchangeUser['email'])->first();
|
||||
if (!$user) {
|
||||
$user = User::find(1);
|
||||
}
|
||||
}
|
||||
$model->status = ApprovalStatus::REJECTED;
|
||||
$model->approver = Auth()->user()->id;
|
||||
$model->approver = $user->id;
|
||||
$model->approval_date = Carbon::now();
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
@@ -12,7 +12,7 @@ class CanApproveDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -36,4 +36,4 @@ class CanApproveDocument extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -50,4 +50,4 @@ class CanCreateDocument extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanCreateFile extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -50,4 +50,4 @@ class CanCreateFile extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanListDocuments extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -44,4 +44,4 @@ class CanListDocuments extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class CanRenderDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -36,4 +36,4 @@ class CanRenderDocument extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class CanUpdateDocument extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -50,4 +50,4 @@ class CanUpdateDocument extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CanUpdateDocumentReference extends AbstractRule
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
@@ -36,4 +36,4 @@ class CanUpdateDocumentReference extends AbstractRule
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Services\ExportsFeedback;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportFeedback;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportFeedbackDataLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Feedback',
|
||||
'message' => 'You have successfully exported feedback data'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ExportsFeedback */
|
||||
private $exportsFeedback;
|
||||
|
||||
/** @var CanExportFeedback */
|
||||
private $canExportFeedback;
|
||||
|
||||
/**
|
||||
* ExportFeedbackDataLogic constructor.
|
||||
* @param ExportsFeedback $exportsFeedback
|
||||
* @param CanExportFeedback $canExportFeedback
|
||||
*/
|
||||
public function __construct(ExportsFeedback $exportsFeedback, CanExportFeedback $canExportFeedback)
|
||||
{
|
||||
$this->exportsFeedback = $exportsFeedback;
|
||||
$this->canExportFeedback = $canExportFeedback;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportFeedback->passes();
|
||||
|
||||
$response = $this->exportsFeedback->download('feedback.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\Abstract2ControllerLogic;
|
||||
use App\Classes\Modules\Exports\Standards\Rules\CanExportPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsOnHoldPackingList;
|
||||
use App\Classes\Modules\Exports\Services\ExportsPendingArrangementDeliveryList;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
class ExportPackingListLogic extends Abstract2ControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved PackingList',
|
||||
'message' => 'You have successfully exported PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var ExportsOnHoldPackingList */
|
||||
private $exportsOnHoldPackingList;
|
||||
|
||||
/** @var ExportsPendingArrangementDeliveryList */
|
||||
private $exportsPendingArrangementDeliveryList;
|
||||
|
||||
/** @var CanExportPackingList */
|
||||
private $canExportPackingList;
|
||||
|
||||
/**
|
||||
* ExportPackingListLogic constructor.
|
||||
* @param ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList
|
||||
* @param ExportsOnHoldPackingList $exportsOnHoldPackingList
|
||||
* @param CanExportPackingList $canExportPackingList
|
||||
*/
|
||||
public function __construct(ExportsPendingArrangementDeliveryList $exportsPendingArrangementDeliveryList, ExportsOnHoldPackingList $exportsOnHoldPackingList, CanExportPackingList $canExportPackingList)
|
||||
{
|
||||
$this->exportsPendingArrangementDeliveryList = $exportsPendingArrangementDeliveryList;
|
||||
$this->exportsOnHoldPackingList = $exportsOnHoldPackingList;
|
||||
$this->canExportPackingList = $canExportPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function logic(Request $request) : BinaryFileResponse
|
||||
{
|
||||
$this->canExportPackingList->passes();
|
||||
$isSetPendingArrangement = $request->header('PendingArrangement');
|
||||
if($isSetPendingArrangement){
|
||||
$response = $this->exportsPendingArrangementDeliveryList->download('packing-list-delivery.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
else {
|
||||
$response = $this->exportsOnHoldPackingList->download('packing-list-on-hold.xls', Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
}
|
||||
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\PackingList;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use App\Classes\General\Eloquent\ApplyFiltersToQuery;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use DateTime;
|
||||
|
||||
class ExportsAgingList implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $filters;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->filters = [
|
||||
"has_invoice_status_in" => [2],
|
||||
"packing_list_ordered_by_invoice_date" => true,
|
||||
"with_aging_column" => true
|
||||
];
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Company Name',
|
||||
'Customer Marking',
|
||||
'Order Number',
|
||||
'Invoice No',
|
||||
'Invoice Date',
|
||||
'Days',
|
||||
'Amount',
|
||||
];
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
return (new ApplyFiltersToQuery())->execute(PackingList::query(), $this->filters);
|
||||
}
|
||||
|
||||
public function map($list): array
|
||||
{
|
||||
$marking = null;
|
||||
$orderNo = null;
|
||||
$name = null;
|
||||
$invDate = 'n/a';
|
||||
$invNo = 'n/a';
|
||||
$days = 'n/a';
|
||||
|
||||
if ($list->owner instanceof Order) {
|
||||
$inviterPivotInviteeReference = $list->owner->companyModule->inviters()->withPivot('invitee_reference')->first();
|
||||
|
||||
if ($inviterPivotInviteeReference) {
|
||||
$marking = $inviterPivotInviteeReference->pivot->invitee_reference;
|
||||
$orderNo = $list->owner->reference;
|
||||
}
|
||||
$name = $list->owner->companyModule->company->name;
|
||||
}
|
||||
|
||||
$transaction = $list->transactions()->whereIn('status', [ApprovalStatus::APPROVED])->first();
|
||||
if ($transaction) {
|
||||
|
||||
$invoiceDate = $transaction->created_at;
|
||||
$invDate = date_format($invoiceDate, 'd-m-Y');
|
||||
$invNo = $transaction->bill_no;
|
||||
$amt = number_format($transaction->amount, 2);
|
||||
|
||||
$currentDate = new DateTime();
|
||||
$interval = $currentDate->diff($invoiceDate);
|
||||
$days = $interval->format('%a');
|
||||
}
|
||||
|
||||
return [
|
||||
$name,
|
||||
$marking,
|
||||
$orderNo,
|
||||
$invNo,
|
||||
$invDate,
|
||||
$days,
|
||||
$amt,
|
||||
];
|
||||
}
|
||||
|
||||
private function dueDateColumn($colNum, $dueDateNumber, $amt)
|
||||
{
|
||||
if ($colNum == $dueDateNumber) return $amt;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,17 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
|
||||
class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize, FromQuery
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
private $start_date;
|
||||
private $end_date;
|
||||
|
||||
public function __construct($start_date = null, $end_date = null)
|
||||
{
|
||||
$this->start_date = $start_date;
|
||||
$this->end_date = $end_date;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
@@ -26,38 +34,49 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
||||
'Warehouse',
|
||||
'Cbm',
|
||||
'Description',
|
||||
'quantity',
|
||||
'Quantity',
|
||||
'Received Date',
|
||||
'Recorded On',
|
||||
'Days to Record',
|
||||
'Remarks'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return PackingList::where('type', '=', 1)->where('status', '=', 2)->where('owner_type', Order::class);
|
||||
$query = PackingList::with([
|
||||
'owner.companyModule.inviters',
|
||||
'owner.orderRoles',
|
||||
'packages',
|
||||
'transports'
|
||||
])
|
||||
->where('type', '=', 1)
|
||||
->where('status', '=', 2)
|
||||
->where('owner_type', Order::class);
|
||||
|
||||
if (!is_null($this->start_date) && !is_null($this->end_date)) {
|
||||
$query->whereHas('transports', function ($q) {
|
||||
$q->whereBetween('drop_date', [
|
||||
Carbon::parse($this->start_date)->startOfDay(),
|
||||
Carbon::parse($this->end_date)->endOfDay()
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $packingList
|
||||
* @return array
|
||||
*/
|
||||
public function map($packingList): array
|
||||
{
|
||||
$order = $packingList->owner;
|
||||
|
||||
$connection = $order->companyModule()->first()->inviters()->withPivot('invitee_reference')->first();
|
||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
||||
|
||||
$warehouse = $order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee;
|
||||
|
||||
$cbm = $packingList->packages->sum(function($package){
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
$marking = $order->companyModule->getMarking();
|
||||
$warehouse = $order->orderRoles->firstWhere('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->appointee;
|
||||
$cbm = $packingList->packages->sum(function ($package) {
|
||||
return (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity;
|
||||
});
|
||||
|
||||
$arrival_date = $packingList->transports()->first()->drop_date->format('d-m-Y');
|
||||
$arrival_date = $packingList->transports->first()->drop_date->format('d-m-Y');
|
||||
$recorded_on = $packingList->created_at->format('d-m-Y');
|
||||
$days_to_record = Carbon::parse($arrival_date)->diffInDays(Carbon::parse($recorded_on));
|
||||
|
||||
return [
|
||||
$packingList->owner->reference,
|
||||
@@ -67,7 +86,9 @@ class ExportsArrivedParcel implements WithHeadings, WithHeadingRow, WithMapping,
|
||||
$packingList->packages->implode('description', ', '),
|
||||
$packingList->packages->sum('quantity'),
|
||||
$arrival_date,
|
||||
$recorded_on,
|
||||
$days_to_record,
|
||||
''
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Company;
|
||||
use App\Models\Wallet;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ExportsCustomersWalletTransactionHistory implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
use Exportable;
|
||||
|
||||
private $request;
|
||||
private $runningBalance = 0;
|
||||
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Date',
|
||||
'Description',
|
||||
'Incoming',
|
||||
'Outgoing',
|
||||
'Balance',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
$wallet = Wallet::find($this->request->route('wallet_id'));
|
||||
$transactions = $wallet->transactions()->whereIn('transactions.status', [2, 3])->orderBy('id');
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($transaction): array
|
||||
{
|
||||
$decimals = $this->request->route('is_precise') == 'true' ? 5 : 2;
|
||||
|
||||
$description = '';
|
||||
switch ((int) $transaction->type) {
|
||||
case TransactionType::TOP_UP:
|
||||
$description = (float) $transaction->amount . ' Credit Top up';
|
||||
break;
|
||||
case TransactionType::GROUP_PAYMENT:
|
||||
$description = (float) $transaction->amount . ' Credit Top up';
|
||||
break;
|
||||
case TransactionType::CREDIT_NOTE:
|
||||
$description = 'Credit Voucher for ' . $transaction->payment_reference;
|
||||
break;
|
||||
case TransactionType::PAYMENT:
|
||||
$booking = Transaction::where('payment_reference', $transaction->bill_no)->first()->owner;
|
||||
|
||||
if (!$booking) {
|
||||
$description = 'Payment for unknown booking, please contact tech support.';
|
||||
break;
|
||||
}
|
||||
|
||||
$marking = $booking->marking;
|
||||
$description = 'Payment For booking refs' . $marking;
|
||||
break;
|
||||
case TransactionType::DEBIT_NOTE:
|
||||
$description = 'Debit Voucher for ' . $transaction->payment_reference;
|
||||
break;
|
||||
}
|
||||
|
||||
$incoming = $outgoing = '';
|
||||
|
||||
if (in_array($transaction->type, [TransactionType::TOP_UP, TransactionType::CREDIT_NOTE, TransactionType::GROUP_PAYMENT])) {
|
||||
$incoming = number_format($transaction->amount, $decimals, '.', ',');
|
||||
$this->runningBalance += $transaction->amount;
|
||||
}
|
||||
|
||||
if (in_array($transaction->type, [TransactionType::PAYMENT, TransactionType::DEBIT_NOTE])) {
|
||||
$outgoing = number_format($transaction->amount, $decimals, '.', ',');
|
||||
$this->runningBalance -= $transaction->amount;
|
||||
}
|
||||
|
||||
return [
|
||||
Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'),
|
||||
$description,
|
||||
$incoming,
|
||||
$outgoing,
|
||||
number_format($this->runningBalance, $decimals, '.', ',')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Exports\Services;
|
||||
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use App\Classes\ValueObjects\Constants\QASystemSourceType;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportsFeedback implements FromQuery, WithHeadings, WithHeadingRow, WithMapping, ShouldAutoSize
|
||||
{
|
||||
|
||||
use Exportable;
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Question Set',
|
||||
'Question Text',
|
||||
'Answer',
|
||||
'Source System',
|
||||
'Source Marking',
|
||||
'Source Email',
|
||||
'Created Date'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection|mixed
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return QAUserAnswerSelected::whereHas('question', function ($query) {
|
||||
$query->whereHas('questionnaire', function ($innerQuery) {
|
||||
$innerQuery->where('group', 'feedback');
|
||||
}); //->where('created_at', '>', Carbon::now()->subMonths(1));
|
||||
})->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QAUserAnswerSelected $userAnswer
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map($userAnswer): array
|
||||
{
|
||||
$source = $userAnswer->userSource;
|
||||
$user = $userAnswer->source_id === 0 ? $userAnswer->user : null;
|
||||
$user_marking = '';
|
||||
if($user){
|
||||
$companyModule = $user->companyModule()->first();
|
||||
$user_marking = $companyModule ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : "";
|
||||
}
|
||||
|
||||
return [
|
||||
$userAnswer->question->questionnaire->description,
|
||||
$userAnswer->question->question_text,
|
||||
$userAnswer->free_text_answer,
|
||||
$user ? QASystemSourceType::getText(QASystemSourceType::IZYIM) : QASystemSourceType::getText($source->system),
|
||||
$user ? $user_marking : $source->marking,
|
||||
$user ? $user->email : $source->email,
|
||||
Carbon::parse($userAnswer->created_at)->format('d-m-Y'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
'DocNo',
|
||||
'DocDate',
|
||||
'DebtorCode',
|
||||
'Ref',
|
||||
'ShipInfo',
|
||||
'AccNo',
|
||||
'DetailDescription',
|
||||
@@ -126,6 +127,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
||||
$transaction->created_at->format('m/d/Y H:m'),
|
||||
$company->debtor,
|
||||
$order->reference,
|
||||
$order->reference,
|
||||
'500-0000',
|
||||
'X1 Freight Service Charge',
|
||||
$furtherDescription,
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -31,8 +32,10 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user