mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
Compare commits
414 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12710f614b | |||
| dcec8cb33b | |||
| 75037f6192 | |||
| 675324081b | |||
| a959e83f5b | |||
| 2802e3c366 | |||
| aac2a0666a | |||
| 19efba4b89 | |||
| 7d70c800db | |||
| 863dc94dad | |||
| 98e45e27e3 | |||
| df2916594b | |||
| a49920973e | |||
| d129f8f6bd | |||
| 55a82e52a4 | |||
| 1d4ac80b8f | |||
| 7cd376a9b5 | |||
| c7e3091f9b | |||
| 28feba2ae9 | |||
| 6176135f85 | |||
| 5f529965da | |||
| 924f4f2ace | |||
| 6369282b38 | |||
| 1991cf2c57 | |||
| 5f5bbe0c8c | |||
| a809aec9a7 | |||
| 68ce8373e9 | |||
| e5347f56b7 | |||
| 6673a44137 | |||
| 4d3345f613 | |||
| 60b8657773 | |||
| 9f7a8d0d4b | |||
| a87ab6c27f | |||
| 462a4776cd | |||
| 7e029c5610 | |||
| 0719285286 | |||
| 64400d1524 | |||
| be0279f56b | |||
| e15170bc7f | |||
| 59f527aee7 | |||
| d7aa248972 | |||
| 8e4ff6093e | |||
| 584169e173 | |||
| 1679d1ecf4 | |||
| 7ca48e9638 | |||
| 14278a888a | |||
| 5de2554d63 | |||
| 033a835fce | |||
| 66ddb5da23 | |||
| 65782ebf8a | |||
| 96a089df16 | |||
| f95545a985 | |||
| 9e8685bd02 | |||
| 1224735ba8 | |||
| 11e2390059 | |||
| c280da36d7 | |||
| 27529e90ca | |||
| 2e9b0f918c | |||
| 5565d0b39b | |||
| f1b8c6a556 | |||
| 6d210d3713 | |||
| 5dd2df02fd | |||
| b207b11336 | |||
| ffd95ee1cc | |||
| 73b3995367 | |||
| 45a2544b9d | |||
| 252636a7df | |||
| 3e679fef23 | |||
| 758498f486 | |||
| b55e32aece | |||
| 00bf7c0cf4 | |||
| 24a4d269b3 | |||
| f191979a53 | |||
| c9998029b0 | |||
| a442c78156 | |||
| 03c5ced77b | |||
| 5c6418cb1f | |||
| 5e636862bb | |||
| e97cbfa618 | |||
| a448172521 | |||
| 72ac055ec5 | |||
| 09383a45a6 | |||
| bb1540116c | |||
| 141062a7bf | |||
| 4179706e04 | |||
| eaa21beb83 | |||
| 1acc02eb93 | |||
| 1f2959a5d2 | |||
| 9b7b7068e1 | |||
| 41e1c346f6 | |||
| 74e9b23f91 | |||
| f949877a7f | |||
| 1e876dd103 | |||
| 3d79d0f5e5 | |||
| 2dc037c8fd | |||
| aaae8bcafa | |||
| b66dfa8649 | |||
| 2689296a2c | |||
| 62191c2711 | |||
| 02cb21bd5a | |||
| 78573db17d | |||
| af1b6ac373 | |||
| d807e5d4fd | |||
| c427ae42a0 | |||
| 8a7a4ce38a | |||
| 1b6fe7445e | |||
| 7b2d0c4e2b | |||
| 1bcad555a0 | |||
| 2973547e76 | |||
| 0b415e2e33 | |||
| 1110838e35 | |||
| 9d87987488 | |||
| 4c0984c9b8 | |||
| 5517f16684 | |||
| 4b967981dd | |||
| e63b959714 | |||
| a1751f274d | |||
| ef6538feca | |||
| de61d9a9fd | |||
| 2c1b857255 | |||
| 5b4a3507a3 | |||
| 3d6543e467 | |||
| 006a327a5f | |||
| 295e6454b1 | |||
| f389efa6af | |||
| f83c89b5f3 | |||
| 4ea3132334 | |||
| 8fc3ac1b55 | |||
| ed252e630b | |||
| b6c9c8843d | |||
| d80e996d02 | |||
| 064ee3e41a | |||
| 3bda84dac5 | |||
| e2b378e197 | |||
| 0f2e1297e1 | |||
| d034a285fc | |||
| ee94943d00 | |||
| a9e89a45bd | |||
| f6b10b5763 | |||
| 9b9057ea81 | |||
| 33d2d02cb0 | |||
| e5be6eaceb | |||
| a545e6bad6 | |||
| b64b25ff05 | |||
| d1426c7f05 | |||
| 3375934651 | |||
| c79f58d246 | |||
| ee17ac0b0c | |||
| 26742a7335 | |||
| 0e822ff1dd | |||
| 085b8b349f | |||
| c1164397e8 | |||
| 3c16253795 | |||
| 18a201611e | |||
| 7e754a9c7b | |||
| beb200fd6a | |||
| f0cb7828c3 | |||
| 1956a4095d | |||
| 71559701f4 | |||
| 9ceba30680 | |||
| 3b2d06ed8f | |||
| 81e04e9cb0 | |||
| 286ca64413 | |||
| 51a96812fd | |||
| 07459b9a1b | |||
| ee69f9123c | |||
| 7a2ed92147 | |||
| 894481591d | |||
| e5580c2abd | |||
| 47ee304da1 | |||
| 6427e2996f | |||
| f54aae5dc9 | |||
| f0ef9a5602 | |||
| 4d682c2ac6 | |||
| 8ea00e0383 | |||
| e0805a9601 | |||
| 6f36c4b7ee | |||
| 87194794f2 | |||
| b4eca67a2f | |||
| 1770b06498 | |||
| 5c9fd6e2a6 | |||
| 18df1c0c7b | |||
| 359c103d01 | |||
| ed7a636a18 | |||
| 19bd548127 | |||
| 55ac8064b1 | |||
| e7279ec4d0 | |||
| a7d4299897 | |||
| 2b507d1006 | |||
| 782a5c33ad | |||
| 6d3a2d9259 | |||
| 730b3d439a | |||
| 6b09d5facc | |||
| 138a4f1cf6 | |||
| b54d897060 | |||
| c12959b4a8 | |||
| f94f380c16 | |||
| f46ec19f01 | |||
| c7a6a5b020 | |||
| 8f64769214 | |||
| cb74228a68 | |||
| b22cc0f7e3 | |||
| 2e8ba4f630 | |||
| e987838d5a | |||
| 4c532deb4d | |||
| 12f05b7aa6 | |||
| 48fa67ae8c | |||
| 1e9e94b581 | |||
| 67653b60fb | |||
| 26fffb8af1 | |||
| 5cdbc09c5b | |||
| c9877bb53e | |||
| 0bf84fa7b1 | |||
| fb0c74d645 | |||
| 53293f26d6 | |||
| 56fe5520ad | |||
| 4c9235cc53 | |||
| babd492caa | |||
| 3d1d1cce11 | |||
| 820d96858f | |||
| 058ba592bf | |||
| d950ee3d68 | |||
| 61c801e216 | |||
| 6f0acec390 | |||
| 76e3668563 | |||
| ce94dd1393 | |||
| c1ea087c58 | |||
| 8595d0987f | |||
| 48d0460eef | |||
| 06751fdc78 | |||
| da6ec00dbd | |||
| 412dbd64d5 | |||
| 496df549f6 | |||
| 97eaefa45a | |||
| 68c9e0451a | |||
| b5bcd5c553 | |||
| 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 |
+6
-4
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
|||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=shpping_portal
|
DB_DATABASE=laravel
|
||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=root
|
DB_PASSWORD=
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
@@ -56,8 +56,10 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
|||||||
|
|
||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
|
||||||
|
|
||||||
PERFEXCRM_BASE_URL=""
|
PERFEXCRM_BASE_URL=""
|
||||||
PERFEXCRM_API_KEY=""
|
PERFEXCRM_API_KEY=""
|
||||||
PERFEXCRM_IS_ENABLED="false"
|
PERFEXCRM_IS_ENABLED="false"
|
||||||
|
|
||||||
|
|
||||||
|
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
||||||
|
SST_START_DATE="2024-04-01 00:00:00"
|
||||||
|
|||||||
@@ -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/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/tests/_output
|
|
||||||
/tests/_support
|
|
||||||
/vendor
|
/vendor
|
||||||
**/.idea/
|
**/.idea/
|
||||||
.env
|
.env
|
||||||
|
|||||||
-120
@@ -1,120 +0,0 @@
|
|||||||
image: php:7.4
|
|
||||||
stages:
|
|
||||||
- service_build
|
|
||||||
- node
|
|
||||||
- building_assets
|
|
||||||
- database
|
|
||||||
- unit_test
|
|
||||||
- acceptance_test
|
|
||||||
- code_quality
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
variables:
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
MYSQL_USER: mysql_password
|
|
||||||
MYSQL_PASSWORD: mysql_password
|
|
||||||
MYSQL_DATABASE: shpping_portal
|
|
||||||
DB_HOST: mysql
|
|
||||||
|
|
||||||
|
|
||||||
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 MySQL client
|
|
||||||
- apt-get install -y default-mysql-client
|
|
||||||
|
|
||||||
#install node js
|
|
||||||
- apt-get update && apt-get install -y nodejs npm
|
|
||||||
|
|
||||||
#install gulp Js
|
|
||||||
- npm install -g gulp-cli
|
|
||||||
|
|
||||||
|
|
||||||
#jobs
|
|
||||||
|
|
||||||
#buld the backend
|
|
||||||
composer_php:
|
|
||||||
stage: service_build
|
|
||||||
script:
|
|
||||||
- composer install
|
|
||||||
- cp .env.example .env
|
|
||||||
- php artisan key:generate
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
|
||||||
|
|
||||||
#build the UI
|
|
||||||
#node installation
|
|
||||||
npm:
|
|
||||||
stage: node
|
|
||||||
script:
|
|
||||||
- npm install # Install npm dependencies
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
|
||||||
|
|
||||||
#building assets
|
|
||||||
building_assets:
|
|
||||||
stage: building_assets
|
|
||||||
# dependencies:
|
|
||||||
# - npm
|
|
||||||
script:
|
|
||||||
- npm install # Install npm dependencies
|
|
||||||
- gulp build # Build assets
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
|
||||||
|
|
||||||
#mysql
|
|
||||||
database:
|
|
||||||
stage: database
|
|
||||||
services:
|
|
||||||
- name: mysql:8.0
|
|
||||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
|
||||||
#dependencies:
|
|
||||||
# - composer_php
|
|
||||||
script:
|
|
||||||
- composer install
|
|
||||||
- cp .env.example .env
|
|
||||||
- php artisan key:generate
|
|
||||||
- php artisan migrate:fresh
|
|
||||||
- php artisan db:seed
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
|
||||||
|
|
||||||
#mysql
|
|
||||||
#unit_test:
|
|
||||||
# stage: unit_test
|
|
||||||
# services:
|
|
||||||
# - name: mysql:8.0
|
|
||||||
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
|
||||||
#dependencies:
|
|
||||||
# - database
|
|
||||||
# script:
|
|
||||||
# - npm install # Install npm dependencies
|
|
||||||
# - gulp build # Build assets
|
|
||||||
# - composer install
|
|
||||||
# - cp .env.example .env
|
|
||||||
# - php artisan key:generate
|
|
||||||
# - php artisan migrate:fresh
|
|
||||||
# - php artisan db:seed
|
|
||||||
# - php artisan test
|
|
||||||
# rules:
|
|
||||||
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
- add running and setting selenium on all OS if possible
|
- [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,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Exceptions;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||||
|
|
||||||
|
final class JobResourceNotFoundException extends ServiceApiException {
|
||||||
|
public function __construct(?string $message = null) {
|
||||||
|
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Classes\Exceptions\JobResourceNotFoundException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
abstract class AbstractControllerLogic
|
abstract class AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -62,6 +64,19 @@ abstract class AbstractControllerLogic
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
|
if ($exception instanceof JobResourceNotFoundException) {
|
||||||
|
Log::channel('vue_polling')->info(sprintf(
|
||||||
|
"Uncaught exception '%s' with message '%s' in %s:%d",
|
||||||
|
get_class($exception),
|
||||||
|
$exception->getMessage(),
|
||||||
|
$exception->getTrace()[0]['file'],
|
||||||
|
$exception->getTrace()[0]['line']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log::error($exception);
|
||||||
|
}
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
abstract class AbstractRule
|
abstract class AbstractRule
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function authorized(): bool;
|
abstract protected function authorized($object): bool;
|
||||||
|
|
||||||
abstract protected function validators($object): bool;
|
abstract protected function validators($object): bool;
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
|||||||
*/
|
*/
|
||||||
public function passes(?DataTransferObject $object = null): bool {
|
public function passes(?DataTransferObject $object = null): bool {
|
||||||
try {
|
try {
|
||||||
if(!$this->authorized()){
|
if(!$this->authorized($object)){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators($object);
|
$this->validators($object);
|
||||||
@@ -36,11 +36,11 @@ abstract class AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(AccessForbiddenException $exception){
|
} 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){
|
} catch(\Exception $exception){
|
||||||
throw new RequestValidationException($exception->getMessage());
|
throw new RequestValidationException($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace App\Classes\General\Eloquent;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use App\Classes\Exceptions\JobResourceNotFoundException;
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractFetchRecord extends AbstractGetRecord
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
||||||
{
|
{
|
||||||
@@ -26,12 +28,18 @@ abstract class AbstractFetchRecord extends AbstractGetRecord
|
|||||||
* @return Model
|
* @return Model
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query): Model {
|
public function getResults(Builder $query, array $param = []): Model {
|
||||||
if(!$query->exists()){
|
if(!$query->exists()){
|
||||||
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
$table = $query->getModel()->getTable();
|
||||||
|
if($table ==='job_results'){
|
||||||
|
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->first();
|
return $query->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ abstract class AbstractGetRecord
|
|||||||
* @param array $filters
|
* @param array $filters
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handler(array $filters){
|
public function handler(array $filters, array $params = []){
|
||||||
$this->filters = collect($filters);
|
$this->filters = collect($filters);
|
||||||
return $this->getResults($this->applyFiltersToQuery());
|
return $this->getResults($this->applyFiltersToQuery(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +65,6 @@ abstract class AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract function getResults(Builder $query);
|
abstract function getResults(Builder $query, array $params = []);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(array $filters = []){
|
public function execute(array $filters = [], array $param = []){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
return $this->handler($filters, $param);
|
||||||
return $this->handler($filters);
|
|
||||||
|
|
||||||
} catch (QueryException $exception){
|
} catch (QueryException $exception){
|
||||||
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
||||||
@@ -32,7 +31,7 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query) {
|
public function getResults(Builder $query, array $param = []) {
|
||||||
$filters = $this->getDecorationFilters();
|
$filters = $this->getDecorationFilters();
|
||||||
|
|
||||||
if($filters->has('order_by')){
|
if($filters->has('order_by')){
|
||||||
@@ -44,8 +43,12 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dd($query->toSql());
|
//dd($query->toSql());
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
if(!empty($param)){
|
||||||
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class JobId implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('job_id', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class OrderByIdDesc implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->orderBy('id', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class OrderByUpdatedAtDesc implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->orderBy('updated_at', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ class OwnerId implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
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)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->where('owner_type', $value);
|
$table = $builder->getModel()->getTable();
|
||||||
|
return $builder->where("{$table}.owner_type", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
||||||
|
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
||||||
|
$join->where('transactions.owner_type', '=', PackingList::class);
|
||||||
|
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
||||||
|
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
||||||
|
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
||||||
|
))');
|
||||||
|
})->orderBy('transactions.updated_at', 'DESC');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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 PostcodeLike implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class RequestSignature implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('request_signature', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class ResultNotNull implements Filter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->whereNotNull('result');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
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,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class WithContainersPackages implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
// Log::info('WithContainersPackages: '.$value);
|
||||||
|
// return $builder->with(['containers', 'packages']);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class WithTrashed implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->withTrashed();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Classes\General;
|
namespace App\Classes\General;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -24,12 +25,11 @@ class Helper
|
|||||||
return array_slice(get_class_methods($className), 1);
|
return array_slice(get_class_methods($className), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $log
|
* @param $log
|
||||||
* @return none
|
|
||||||
*/
|
*/
|
||||||
static function debugLoggerForPerfexCRM($log){
|
static function debugLogger($log){
|
||||||
if($log){
|
if($log && isset($log['message'])){
|
||||||
$message = $log['message'];
|
$message = $log['message'];
|
||||||
$substring = 'No data were found';
|
$substring = 'No data were found';
|
||||||
if (isset($message)) {
|
if (isset($message)) {
|
||||||
@@ -41,4 +41,12 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ResourceCollection $collection
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
static function collectionResponse(ResourceCollection $collection){
|
||||||
|
return json_decode($collection->response()->getContent(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
||||||
|
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
class ListPackingListsJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $timeout = 900;
|
||||||
|
|
||||||
|
/** @var ListGenericJobObject */
|
||||||
|
private $listGenericJobObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ListPackingListsJob constructor.
|
||||||
|
* @param ListGenericJobObject $listGenericJobObject
|
||||||
|
*/
|
||||||
|
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||||
|
{
|
||||||
|
$this->listGenericJobObject = $listGenericJobObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$rawPayload = $this->job->payload();
|
||||||
|
if(isset($rawPayload['data']['commandName'])){
|
||||||
|
$this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($rawPayload['data']['command'])){
|
||||||
|
$this->listGenericJobObject->setJobCommand($rawPayload['data']['command']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->listGenericJobObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||||
|
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
||||||
|
use App\Models\Transaction;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@@ -10,6 +12,8 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
class UpdatePerfexCRM implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -18,37 +22,51 @@ class UpdatePerfexCRM implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMInvoice */
|
|
||||||
private $nextJob;
|
|
||||||
|
|
||||||
/** @var */
|
/** @var */
|
||||||
private $transaction;
|
private $transaction;
|
||||||
|
|
||||||
|
/** @var bool|null */
|
||||||
|
private $shouldCreateInvoice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRM constructor.
|
* UpdatePerfexCRM constructor.
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
* @param UpdatePerfexCRMInvoice $nextJob
|
* @param Transaction $transaction
|
||||||
* @param $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->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
$this->nextJob = $nextJob;
|
|
||||||
$this->transaction = $transaction;
|
$this->transaction = $transaction;
|
||||||
|
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
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);
|
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||||
if($this->nextJob != null && $this->transaction != null){
|
if($this->transaction != null && $this->shouldCreateInvoice){
|
||||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
$this->updatePerfexCRMObject->getContactEmail(),
|
||||||
$result->projectId,
|
$result->projectId,
|
||||||
$this->transaction,
|
$this->transaction,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
/** @var UpdatePerfexCRMInvoice $nextJob */
|
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
||||||
$this->nextJob::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\UpdatePerfexCRMInvoiceObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use App\Classes\General\Helper;
|
use App\Classes\General\Helper;
|
||||||
|
|
||||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||||
@@ -32,7 +30,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
* CreatePerfexCRMSingleTask constructor.
|
||||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
||||||
*/
|
*/
|
||||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||||
{
|
{
|
||||||
@@ -49,7 +47,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = 0;
|
$invoiceId = 0;
|
||||||
$invoiceStatus = 0;
|
$invoiceStatus = 0;
|
||||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
$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::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
|
|
||||||
if(is_null($invoice)){
|
if(is_null($invoice)){
|
||||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
||||||
@@ -57,7 +55,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
|||||||
$invoiceId = $result->payload['id'];
|
$invoiceId = $result->payload['id'];
|
||||||
} else {
|
} else {
|
||||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
||||||
Helper::debugLoggerForPerfexCRM('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
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
|
//This only run when invoice already exist and the invoice does not have a PAID status
|
||||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
||||||
Log::error(json_encode('UpdatePerfexCRMInvoice debug $this->updatePerfexCRMInvoiceObject->getProjectId(): '.$this->updatePerfexCRMInvoiceObject->getProjectId()));
|
|
||||||
//update invoice
|
//update invoice
|
||||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,27 +27,22 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
/** @var UpdatePerfexCRM */
|
/** @var bool|null */
|
||||||
private $nextJob1;
|
private $shouldCreateInvoice;
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMInvoice */
|
|
||||||
private $nextJob2;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRMPrelude constructor.
|
* UpdatePerfexCRMPrelude constructor.
|
||||||
* @param $packingList
|
* @param $packingList
|
||||||
* @param $transaction
|
* @param Transaction $transaction
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
* @param UpdatePerfexCRM $nextJob1
|
* @param bool|null $shouldCreateInvoice
|
||||||
* @param UpdatePerfexCRMInvoice $nextJob2
|
|
||||||
*/
|
*/
|
||||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||||
{
|
{
|
||||||
$this->packingList = $packingList;
|
$this->packingList = $packingList;
|
||||||
$this->transaction = $transaction;
|
$this->transaction = $transaction;
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
$this->nextJob1 = $nextJob1;
|
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||||
$this->nextJob2 = $nextJob2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
@@ -69,9 +64,7 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
|||||||
|
|
||||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||||
$this->updatePerfexCRMObject->setTasks($result);
|
$this->updatePerfexCRMObject->setTasks($result);
|
||||||
/** @var UpdatePerfexCRM $nextJob1 */
|
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
||||||
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
|
||||||
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function replacePlaceholders($template, $data, $prefix = '')
|
function replacePlaceholders($template, $data, $prefix = '')
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
|
|||||||
return $this->passwordResetTokenExists->execute($object->getToken());
|
return $this->passwordResetTokenExists->execute($object->getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\General\Interfaces\Contactable;
|
use App\Classes\General\Interfaces\Contactable;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
@@ -20,7 +17,6 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -31,8 +27,7 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Address',
|
'title' => 'Created Address',
|
||||||
'message' => 'You have successfully created a new Address'
|
'message' => 'You have successfully created a new Address'
|
||||||
@@ -79,11 +74,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
@@ -95,22 +90,16 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||||
|
|
||||||
if ($request->input('phone')) {
|
if($request->input('phone')){
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('remark')) {
|
if($request->input('remark')){
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||||
@@ -17,7 +14,6 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -27,8 +23,7 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Billing Address',
|
'title' => 'Created Billing Address',
|
||||||
'message' => 'You have successfully created a new Billing Address'
|
'message' => 'You have successfully created a new Billing Address'
|
||||||
@@ -65,35 +60,27 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||||
|
|
||||||
|
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||||
|
|
||||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||||
|
|
||||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
|
||||||
// delete all current billing address
|
// delete all current billing address
|
||||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||||
|
|
||||||
// create new billing addrress
|
// create 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);
|
$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->canCreateAddress->passes($billingAddress);
|
||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//load address with only owner address
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
/* return fractal()
|
|
||||||
->item($billingAddressInputed, new AddressTransformer())
|
|
||||||
->parseIncludes('Owner_address')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||||
@@ -19,8 +17,7 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Address',
|
'title' => 'Retrieved Address',
|
||||||
'message' => 'You have successfully retrieved a Address'
|
'message' => 'You have successfully retrieved a Address'
|
||||||
@@ -48,22 +45,15 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canFetchAddress->passes();
|
$this->canFetchAddress->passes();
|
||||||
|
|
||||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
|
||||||
//load address with no relationships
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($query));
|
return $this->resourceResponse(new AddressResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,10 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -21,8 +17,7 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Addresses',
|
'title' => 'Retrieved Addresses',
|
||||||
'message' => 'You have successfully retrieved a list of Addresses'
|
'message' => 'You have successfully retrieved a list of Addresses'
|
||||||
@@ -50,25 +45,17 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListAddresses->passes();
|
$this->canListAddresses->passes();
|
||||||
|
|
||||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
//a collection of addresses with all incluides
|
|
||||||
/* return fractal()
|
|
||||||
->collection($query, new AddressTransformer)
|
|
||||||
->parseIncludes('Owner_address')
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->parseIncludes('contact')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->collectionResponse(AddressResource::collection($query));
|
return $this->collectionResponse(AddressResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Http\Resources\DistrictResource;
|
use App\Http\Resources\DistrictResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Http\Resources\StateResource;
|
use App\Http\Resources\StateResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|||||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
/** @var ResetsAddressesDefault */
|
/** @var ResetsAddressesDefault */
|
||||||
private $resetsAddressesDefault;
|
private $resetsAddressesDefault;
|
||||||
|
|
||||||
/** @var SetsAddressToDefault */
|
/** @var SetsAddressToDefault*/
|
||||||
private $setsAddressToDefault;
|
private $setsAddressToDefault;
|
||||||
|
|
||||||
|
|
||||||
@@ -65,15 +64,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||||
|
|
||||||
|
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
|
||||||
//no relationships needed
|
|
||||||
/* return fractal()
|
|
||||||
->item($setAddress, new AddressTransformer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -27,8 +26,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Address',
|
'title' => 'Updated Address',
|
||||||
'message' => 'You have successfully updated the Address'
|
'message' => 'You have successfully updated the Address'
|
||||||
@@ -79,7 +77,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
@@ -92,25 +90,18 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->updatesAddress->execute($address, $object);
|
$address = $this->updatesAddress->execute($address, $object);
|
||||||
|
|
||||||
$address->contacts()->delete();
|
$address->contacts()->delete(); $address->remarks()->delete();
|
||||||
$address->remarks()->delete();
|
|
||||||
|
|
||||||
if ($request->input('phone')) {
|
if($request->input('phone')){
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('remark')) {
|
if($request->input('remark')){
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
//only remark relationship needed
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,4 @@ class CanCreateBank extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteBank extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class CanListBanks extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -34,4 +34,4 @@ class CanListBanks extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateBank extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateBank extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,17 @@ use App\Classes\Exceptions\MalformedRequestException;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
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\Services\FetchesTransaction;
|
||||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Models\Group;
|
use App\Models\Group;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class CallbackBillplzLogic
|
class CallbackBillplzLogic
|
||||||
{
|
{
|
||||||
@@ -46,6 +49,12 @@ class CallbackBillplzLogic
|
|||||||
/** @var CreatePaymentTransactionProcessor */
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
private $createPaymentTransactionProcessor;
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
|
/** @var CallbackBillplzProcessor */
|
||||||
|
private $callbackBillplzProcessor;
|
||||||
|
|
||||||
|
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||||
|
private $storageInvoiceTransactionProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CallbackBillplzLogic constructor.
|
* CallbackBillplzLogic constructor.
|
||||||
* @param GetBillplzBill $getBillplzBill
|
* @param GetBillplzBill $getBillplzBill
|
||||||
@@ -54,8 +63,10 @@ class CallbackBillplzLogic
|
|||||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
|
* @param CallbackBillplzProcessor $callbackBillplzProcessor
|
||||||
|
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
||||||
*/
|
*/
|
||||||
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, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
||||||
{
|
{
|
||||||
$this->getBillplzBill = $getBillplzBill;
|
$this->getBillplzBill = $getBillplzBill;
|
||||||
$this->fetchesTransaction = $fetchesTransaction;
|
$this->fetchesTransaction = $fetchesTransaction;
|
||||||
@@ -64,6 +75,8 @@ class CallbackBillplzLogic
|
|||||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
|
$this->callbackBillplzProcessor = $callbackBillplzProcessor;
|
||||||
|
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,44 +116,13 @@ class CallbackBillplzLogic
|
|||||||
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
$status = $billplzXSignatureObject->getStatus() === 'failed' ? ApprovalStatus::REJECTED : ApprovalStatus::PENDING_VERIFICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::info('Debug billPlz status: '.$status);
|
||||||
|
|
||||||
$token = Auth::fromUser(User::find(1));
|
$token = Auth::fromUser(User::find(1));
|
||||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||||
|
|
||||||
// check if is wallet top up
|
$this->storageInvoiceBackDoorPreventionCheck($transaction, $status);
|
||||||
if($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED &&!in_array($transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) {
|
$result = $this->callbackBillplzProcessor->execute($transaction, $status);
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
$company_module_marking = $transaction->owner->owner->connections? $transaction->owner->owner->connections->first()->invitee_reference: null;
|
||||||
|
|
||||||
@@ -151,6 +133,22 @@ class CallbackBillplzLogic
|
|||||||
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
|
$company_module_marking = $order->companyModule->connections? $order->companyModule->connections->first()->invitee_reference: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status]);
|
return $request->method() === 'POST' ? true : view('pages.payments_redirect', ['marking' => $order->reference ?? null, 'company_module_marking' => $company_module_marking ?? null, 'transaction' => $transaction, 'status' => $status, 'result' => $result]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function storageInvoiceBackDoorPreventionCheck($transaction, $status){
|
||||||
|
if ($transaction->owner instanceof Wallet && $status === ApprovalStatus::APPROVED) {
|
||||||
|
$group = Group::where('reference', $transaction->payment_reference)->first();
|
||||||
|
if ($group) {
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$order = $pL->owner;
|
||||||
|
if($order){
|
||||||
|
$this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?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\PaymentMethodType;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||||
|
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;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CallbackBillplzProcessor
|
||||||
|
{
|
||||||
|
/** @var UpdatesTransactionStatus */
|
||||||
|
private $updatesTransactionStatus;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromVTPortalProcessor */
|
||||||
|
private $updateDoFromVTPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdateDoFromYDPortalProcessor */
|
||||||
|
private $updateDoFromYDPortalProcessor;
|
||||||
|
|
||||||
|
/** @var UpdatesWalletBalance */
|
||||||
|
private $updatesWalletBalance;
|
||||||
|
|
||||||
|
/** @var CreatePaymentTransactionProcessor */
|
||||||
|
private $createPaymentTransactionProcessor;
|
||||||
|
|
||||||
|
/** @var ReleaseGoodsToCustomerProcessor */
|
||||||
|
private $releaseGoodsToCustomerProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateUserProcessor constructor.
|
||||||
|
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||||
|
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||||
|
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||||
|
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||||
|
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||||
|
* @param ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor
|
||||||
|
*/
|
||||||
|
public function __construct(UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor, ReleaseGoodsToCustomerProcessor $releaseGoodsToCustomerProcessor)
|
||||||
|
{
|
||||||
|
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||||
|
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||||
|
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||||
|
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||||
|
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||||
|
$this->releaseGoodsToCustomerProcessor = $releaseGoodsToCustomerProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute($transaction, $status)
|
||||||
|
{
|
||||||
|
$invoice = $transaction->owner;
|
||||||
|
$packingList = $invoice->owner;
|
||||||
|
|
||||||
|
$proceed = $this->checkForGroupPayment($transaction);
|
||||||
|
if(!$proceed) return false;
|
||||||
|
|
||||||
|
$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;
|
||||||
|
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$paymentTransaction = $this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, null, false);
|
||||||
|
|
||||||
|
if($paymentTransaction && $paymentTransaction->status == ApprovalStatus::APPROVED){
|
||||||
|
$pL = $invoice->owner;
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($pL, $invoice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$group->status = $status;
|
||||||
|
$group->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$transaction->owner instanceof Wallet) {
|
||||||
|
$this->releaseGoodsToCustomerProcessor->execute($packingList, $invoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkForGroupPayment($transaction){
|
||||||
|
//This check is targetting group payment that expired and soft deleted
|
||||||
|
//command:check-storage-invoices must already run for this part of the code to work properly
|
||||||
|
$group = Group::withTrashed()->where('reference', $transaction->payment_reference)->first();
|
||||||
|
if ($group) {
|
||||||
|
$totalAmountToBePaid = 0;
|
||||||
|
$actualAmountPaid = $transaction->amount;
|
||||||
|
|
||||||
|
foreach ($group->groupTransactions as $groupTransaction) {
|
||||||
|
$invoice = $groupTransaction->transaction;
|
||||||
|
if($invoice->status !== ApprovalStatus::COMPLETED){
|
||||||
|
$totalAmountToBePaid += $invoice->amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($totalAmountToBePaid - $actualAmountPaid) < 0.01){
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from current transaction: '.$totalAmountToBePaid); //cief todo: to be removed
|
||||||
|
Log::channel('storage_invoices')->info('Total amount from paid transaction: '.$transaction->amount); //cief todo: to be removed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Billplzs\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class DeletesBillplzBill
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $billID
|
||||||
|
* @throws MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute(string $billID) {
|
||||||
|
try{
|
||||||
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->delete(config('billplz.base_url').'/api/v3/bills/'.$billID);
|
||||||
|
Log::channel('storage_invoices')->info('DeletesBillplzBill response: '.json_encode($response));
|
||||||
|
|
||||||
|
if($response->successful()){
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
// $data['url'] = $data['url'].'?auto_submit=true';
|
||||||
|
|
||||||
|
return (object) $data;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}catch(\Exception $exception){
|
||||||
|
throw new MalformedRequestException('Unable to get correct response from billplz server: ' . $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,16 +3,13 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Transformers\CompanyTransformer;
|
use App\Http\Resources\CompanyResource;
|
||||||
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Spatie\Fractalistic\ArraySerializer;
|
|
||||||
|
|
||||||
class ListCompaniesLogic extends AbstractControllerLogic
|
class ListCompaniesLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -48,24 +45,16 @@ class ListCompaniesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
||||||
// return $this->collectionResponse(CompanyResource::collection($query));
|
return $this->collectionResponse(CompanyResource::collection($query));
|
||||||
|
|
||||||
return fractal()
|
|
||||||
->parseIncludes(['owner'])
|
|
||||||
->collection($query, new CompanyTransformer(), "data")
|
|
||||||
->serializeWith(new ArraySerializer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,10 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Http\Resources\CompanyModuleResource;
|
use App\Http\Resources\CompanyModuleResource;
|
||||||
use App\Transformers\CompanyTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -21,8 +17,7 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Company Moduels',
|
'title' => 'Retrieved Company Moduels',
|
||||||
'message' => 'You have successfully retrieved a list of Companies'
|
'message' => 'You have successfully retrieved a list of Companies'
|
||||||
@@ -50,26 +45,15 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
/*include all relationships*/
|
|
||||||
/* return fractal()
|
|
||||||
->collection($query, new CompanyTransformer)
|
|
||||||
->parseIncludes('company')
|
|
||||||
->parseIncludes('contact')
|
|
||||||
->parseIncludes('remarks')
|
|
||||||
->parseIncludes('address')
|
|
||||||
->parseIncludes('billingAddress')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+121
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
|
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||||
|
use App\Classes\Modules\Companies\Services\UpdatesCompanyModuleIsCreditTerm;
|
||||||
|
use App\Classes\Modules\Companies\Standards\Rules\CanUpdateCompanyModule;
|
||||||
|
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||||
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionIsWaived;
|
||||||
|
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\Order;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class UpdateCompanyCreditTermStatusLogic extends AbstractControllerLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function notification():array {
|
||||||
|
return [
|
||||||
|
'title' => 'Update Company Credit Term Status',
|
||||||
|
'message' => 'You have successfully updated Company Credit Term Status'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var FetchesCompany */
|
||||||
|
private $fetchesCompany;
|
||||||
|
|
||||||
|
/** @var UpdatesCompanyModuleIsCreditTerm */
|
||||||
|
private $updatesCompanyModuleIsCreditTerm;
|
||||||
|
|
||||||
|
/** @var CanUpdateCompanyModule */
|
||||||
|
private $canUpdateCompanyModule;
|
||||||
|
|
||||||
|
/** @var ListsTransactions */
|
||||||
|
private $listsTransactions;
|
||||||
|
|
||||||
|
/** @var UpdatesTransactionIsWaived */
|
||||||
|
private $updatesTransactionIsWaived;
|
||||||
|
|
||||||
|
/** @var CheckStorageInvoiceTransactionProcessor */
|
||||||
|
private $storageInvoiceTransactionProcessor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateCompanyCreditTermStatusLogic constructor.
|
||||||
|
* @param FetchesCompany $fetchesCompany
|
||||||
|
* @param UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm
|
||||||
|
* @param CanUpdateCompanyModule $canUpdateCompanyModule
|
||||||
|
* @param UpdatesTransactionIsWaived $updatesTransactionIsWaived
|
||||||
|
* @param ListsTransactions $listsTransactions
|
||||||
|
* @param CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor
|
||||||
|
*/
|
||||||
|
public function __construct(FetchesCompany $fetchesCompany, UpdatesCompanyModuleIsCreditTerm $updatesCompanyModuleIsCreditTerm, CanUpdateCompanyModule $canUpdateCompanyModule, UpdatesTransactionIsWaived $updatesTransactionIsWaived, ListsTransactions $listsTransactions, CheckStorageInvoiceTransactionProcessor $storageInvoiceTransactionProcessor)
|
||||||
|
{
|
||||||
|
$this->fetchesCompany = $fetchesCompany;
|
||||||
|
$this->updatesCompanyModuleIsCreditTerm = $updatesCompanyModuleIsCreditTerm;
|
||||||
|
$this->canUpdateCompanyModule = $canUpdateCompanyModule;
|
||||||
|
$this->listsTransactions = $listsTransactions;
|
||||||
|
$this->updatesTransactionIsWaived = $updatesTransactionIsWaived;
|
||||||
|
$this->storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return JsonResponse
|
||||||
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
|
*/
|
||||||
|
public function logic(Request $request) : JsonResponse
|
||||||
|
{
|
||||||
|
$this->canUpdateCompanyModule->passes();
|
||||||
|
|
||||||
|
$company = $this->fetchesCompany->execute(['id' => $request->route('id')]);
|
||||||
|
$companyModule = $company->companyModules()->first();
|
||||||
|
$isCreditTerm = $companyModule->connections()->first()->is_credit_term;
|
||||||
|
|
||||||
|
if ($isCreditTerm == 1) {
|
||||||
|
$isCreditTerm = 0;
|
||||||
|
} else {
|
||||||
|
$isCreditTerm = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($isCreditTerm === 1){
|
||||||
|
//{"per_page":10,"order_by":{"column":"id","DESC":true},"status_in":[2],"receiver":190,"type_in":[1],"does_not_have_payment_status_in":[0,1],"does_not_have_groups":1,"check_for_storage_invoice":1}
|
||||||
|
|
||||||
|
$filters = [
|
||||||
|
'status_in' => [2],
|
||||||
|
'receiver' => $companyModule->id,
|
||||||
|
'type_in' => [TransactionType::STORAGE_INVOICE]
|
||||||
|
];
|
||||||
|
|
||||||
|
$transactions = $this->listsTransactions->execute($filters);
|
||||||
|
foreach($transactions as $transaction){
|
||||||
|
$this->updatesTransactionIsWaived->execute($transaction);
|
||||||
|
$packingList = $transaction->owner()->first();
|
||||||
|
if($packingList){
|
||||||
|
$order = $packingList->owner()->first();
|
||||||
|
if($order instanceof Order){
|
||||||
|
$storages = $this->storageInvoiceTransactionProcessor->executeOrder($order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updatesCompanyModuleIsCreditTerm->execute($company->companyModules()->first()->connections()->first(), $isCreditTerm);
|
||||||
|
Log::info(Auth::user()->email." updated credit term status for customer with id: " .$request->route('id'). " to status " . $isCreditTerm);
|
||||||
|
|
||||||
|
$result = ['is_credit_term' => $isCreditTerm];
|
||||||
|
return $this->response(['data' => $result]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\Services;
|
||||||
|
|
||||||
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
|
use App\Models\CompanyConnection;
|
||||||
|
|
||||||
|
class UpdatesCompanyModuleIsCreditTerm extends AbstractUpdateRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CompanyConnection $model
|
||||||
|
* @param int $isCreditTerm
|
||||||
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute(CompanyConnection $model, int $isCreditTerm)
|
||||||
|
{
|
||||||
|
$model->is_credit_term = $isCreditTerm;
|
||||||
|
|
||||||
|
return $this->handler($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanAssignEmployee extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanAssignEmployee extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanCreateCompany extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCompanyModule extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanFetchCompany extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanListCompanies extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanListCompanies extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanUpdateCompany extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanUpdateCompany extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Companies\Standards\Rules;
|
||||||
|
|
||||||
|
use App\Classes\General\Abstracts\AbstractRule;
|
||||||
|
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
|
||||||
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
|
||||||
|
class CanUpdateCompanyModule extends AbstractRule
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CanUpdateCompanyModule constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function authorized($object): bool
|
||||||
|
{
|
||||||
|
$user = Auth()->user();
|
||||||
|
if($user){
|
||||||
|
$roleToCheck = Auth()->user()->type;
|
||||||
|
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $object
|
||||||
|
* @return bool
|
||||||
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
|
*/
|
||||||
|
protected function validators($object): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CompanyObject $object
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function criteria($object): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
|||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||||
use App\Http\Resources\ContactResource;
|
use App\Http\Resources\ContactResource;
|
||||||
use App\Transformers\ContactTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -64,13 +63,6 @@ class UpdateContactLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->updatesContact->execute($query, $object);
|
$query = $this->updatesContact->execute($query, $object);
|
||||||
|
|
||||||
/*uniformity*/
|
|
||||||
/* return fractal()
|
|
||||||
->item($query, new ContactTransformer())
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ContactResource($query));
|
return $this->resourceResponse(new ContactResource($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateContact extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanCreateContact extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanCreateCurrency extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -36,4 +36,4 @@ class CanDeleteCurrency extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanFetchCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanFetchCurrency extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanListCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
@@ -38,4 +38,4 @@ class CanListCurrency extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateCurrency extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateCurrency extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CanCreateRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
if (!\Auth::user()->can('add currency_rate')) {
|
if (!\Auth::user()->can('add currency_rate')) {
|
||||||
@@ -52,4 +52,4 @@ class CanCreateRate extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanDeleteRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
@@ -42,4 +42,4 @@ class CanDeleteRate extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanFetchRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanFetchRate extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class CanListRates extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
@@ -42,4 +42,4 @@ class CanListRates extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CanUpdateRate extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized(): bool
|
protected function authorized($object): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
|
|
||||||
@@ -55,4 +55,4 @@ class CanUpdateRate extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
|||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
use App\Http\Resources\DeliveryOrderResource;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Transformers\DeliveryOrderTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -53,14 +52,6 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
/** @var Order $order */
|
/** @var Order $order */
|
||||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
$order = $this->cancelsOrder->execute($order);
|
|
||||||
|
|
||||||
//no relationship needed
|
|
||||||
/* return fractal()
|
|
||||||
->item($order, new DeliveryOrderTransformer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,12 +172,6 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||||
$this->createsPackage->execute($packageObject, $packingList);
|
$this->createsPackage->execute($packageObject, $packingList);
|
||||||
|
|
||||||
//add relationship to order
|
|
||||||
/* return fractal()
|
|
||||||
->item($order, new DeliveryOrderTransformer())
|
|
||||||
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,12 +48,6 @@ class ListOrdersLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||||
|
|
||||||
|
|
||||||
//no relationship needed
|
|
||||||
/* return fractal()
|
|
||||||
->collection($query, new DeliveryOrderTransformer)
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,13 @@
|
|||||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||||
use App\Http\Resources\DocumentResource;
|
use App\Http\Resources\DocumentResource;
|
||||||
use App\Models\Document;
|
|
||||||
use App\Transformers\DocumentTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use League\Fractal\Serializer\ArraySerializer;
|
|
||||||
use League\Fractal;
|
|
||||||
|
|
||||||
|
|
||||||
class ListDocumentLogic extends AbstractControllerLogic
|
class ListDocumentLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -25,8 +17,7 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Document',
|
'title' => 'Retrieved Document',
|
||||||
'message' => 'You have successfully retrieved a list of Document'
|
'message' => 'You have successfully retrieved a list of Document'
|
||||||
@@ -54,29 +45,19 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListDocuments->passes();
|
$this->canListDocuments->passes();
|
||||||
|
|
||||||
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
||||||
|
|
||||||
$data = fractal()
|
return $this->collectionResponse(DocumentResource::collection($query));
|
||||||
->parseIncludes(['owner'])
|
|
||||||
->collection($query, new DocumentTransformer, "data")
|
|
||||||
->serializeWith(new ArraySerializer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user