mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d8391fe479 | |||
| c01e8d6eb2 | |||
| 5aad5f1729 | |||
| 485a6e2e82 | |||
| e7c0e17ee4 | |||
| 569273c058 | |||
| 80f229c6ec | |||
| 56b6b59967 | |||
| 842614700a | |||
| a0ca37ec16 | |||
| 08b2ba1c63 | |||
| c7f8831555 | |||
| df31b801f3 | |||
| 946c9b6e3d | |||
| bafc23bf6f | |||
| 2d13f69be6 | |||
| cb184c8f50 |
+2
-4
@@ -10,9 +10,9 @@ LOG_LEVEL=debug
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
@@ -56,8 +56,6 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
|
||||
PERFEXCRM_BASE_URL=""
|
||||
PERFEXCRM_API_KEY=""
|
||||
PERFEXCRM_IS_ENABLED="false"
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:rIar2fvNeRzQdvKOgLUg03detGDMx6ym2SYFRjawrAc=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=shpping_portal
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=P@ssw0rd
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
UNITY_APP_URL="https://unity.izyim.com"
|
||||
EXCHANGE_URL=https://dev.exchange.cief-malaysia.com/
|
||||
MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
||||
|
||||
YD_API_CODE=''
|
||||
|
||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||
@@ -2,8 +2,6 @@
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/tests/_output
|
||||
/tests/_support
|
||||
/vendor
|
||||
**/.idea/
|
||||
.env
|
||||
|
||||
-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
|
||||
- add running and setting selenium on all OS if possible
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Required Packages :
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
- laravel/legacy-factories
|
||||
## Learning Laravel
|
||||
|
||||
- codeception/codeception
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
|
||||
Or Simply Run
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
``Composer install``
|
||||
## Laravel Sponsors
|
||||
|
||||
To create a unit test
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
|
||||
``php artisan make test: Test Example --unit``
|
||||
### Premium Partners
|
||||
|
||||
Running the tests :
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
|
||||
Running a single Test
|
||||
## Contributing
|
||||
|
||||
`` php artisan test --filter Example``
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
Running Unit tests -
|
||||
## Code of Conduct
|
||||
|
||||
`` php artisan test ``
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
Running Codeception tests -
|
||||
## Security Vulnerabilities
|
||||
|
||||
``vendor/bin/codecept run``
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
|
||||
+4
-6
@@ -4,17 +4,15 @@ namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class OwnerType implements Filter
|
||||
class DoesNotHaveGroups implements Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('owner_type', $value);
|
||||
return $builder->whereDoesntHave('groups');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,14 @@ use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
||||
use App\Models\PackingList;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\General\Helper;
|
||||
|
||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
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\Interfaces\Contactable;
|
||||
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\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -31,8 +27,7 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Address',
|
||||
'message' => 'You have successfully created a new Address'
|
||||
@@ -79,11 +74,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @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')]);
|
||||
@@ -95,22 +90,16 @@ class CreateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$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'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if ($request->input('remark')) {
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||
}
|
||||
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->parseIncludes('remark')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
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\Modules\Addresses\Services\CreatesAddress;
|
||||
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\Models\Address;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -27,8 +23,7 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Billing Address',
|
||||
'message' => 'You have successfully created a new Billing Address'
|
||||
@@ -65,35 +60,27 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @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')]);
|
||||
|
||||
$address = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||
|
||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
if ($address->type !== AddressType::BILLING || $address->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||
// delete all current billing address
|
||||
Address::where('owner_type', CompanyModule::class)->where('owner_id', $request->input('company_module_id'))->where('type', AddressType::BILLING)->delete();
|
||||
|
||||
// create new billing addrress
|
||||
$billingAddress = new AddressObject($billingAddressInputed->street_one, $billingAddressInputed->street_two, $billingAddressInputed->country_id, $billingAddressInputed->state_id, $billingAddressInputed->district_id, $billingAddressInputed->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $billingAddressInputed->reference);
|
||||
// create addrress
|
||||
$billingAddress = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode, AddressType::BILLING, ApprovalStatus::APPROVED, $address->reference);
|
||||
$this->canCreateAddress->passes($billingAddress);
|
||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||
}
|
||||
|
||||
//load address with only owner address
|
||||
|
||||
/* return fractal()
|
||||
->item($billingAddressInputed, new AddressTransformer())
|
||||
->parseIncludes('Owner_address')
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
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\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||
@@ -19,8 +17,7 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Address',
|
||||
'message' => 'You have successfully retrieved a Address'
|
||||
@@ -48,22 +45,15 @@ class FetchAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchAddress->passes();
|
||||
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,10 @@
|
||||
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\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Addresses',
|
||||
'message' => 'You have successfully retrieved a list of Addresses'
|
||||
@@ -50,25 +45,17 @@ class ListAddressesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$this->canListAddresses->passes();
|
||||
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\DistrictResource;
|
||||
use ErrorException;
|
||||
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\ListsStates;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\StateResource;
|
||||
use ErrorException;
|
||||
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\SetsAddressToDefault;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -34,7 +33,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
/** @var ResetsAddressesDefault */
|
||||
private $resetsAddressesDefault;
|
||||
|
||||
/** @var SetsAddressToDefault */
|
||||
/** @var SetsAddressToDefault*/
|
||||
private $setsAddressToDefault;
|
||||
|
||||
|
||||
@@ -65,15 +64,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
||||
|
||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||
|
||||
|
||||
$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));
|
||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Models\Address;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -27,8 +26,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated 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\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
|
||||
@@ -92,25 +90,18 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
||||
/** @var Address $address */
|
||||
$address = $this->updatesAddress->execute($address, $object);
|
||||
|
||||
$address->contacts()->delete();
|
||||
$address->remarks()->delete();
|
||||
$address->contacts()->delete(); $address->remarks()->delete();
|
||||
|
||||
if ($request->input('phone')) {
|
||||
if($request->input('phone')){
|
||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||
$this->createContactProcessor->execute($contactObject, $address);
|
||||
}
|
||||
|
||||
if ($request->input('remark')) {
|
||||
if($request->input('remark')){
|
||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
@@ -4,29 +4,24 @@ namespace App\Classes\Modules\Billplzs\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWallet;
|
||||
|
||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Billplzs\Services\GetBillplzBill;
|
||||
use App\Classes\Modules\Billplzs\DataTransferObjects\BillplzXSignatureObject;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Group;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CallbackBillplzLogic
|
||||
{
|
||||
@@ -48,6 +43,9 @@ class CallbackBillplzLogic
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/**
|
||||
* CallbackBillplzLogic constructor.
|
||||
* @param GetBillplzBill $getBillplzBill
|
||||
@@ -55,8 +53,9 @@ class CallbackBillplzLogic
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
*/
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance)
|
||||
public function __construct(GetBillplzBill $getBillplzBill, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor, UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor, UpdatesWalletBalance $updatesWalletBalance, CreatePaymentTransactionProcessor $createPaymentTransactionProcessor)
|
||||
{
|
||||
$this->getBillplzBill = $getBillplzBill;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
@@ -64,6 +63,7 @@ class CallbackBillplzLogic
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,19 +111,30 @@ class CallbackBillplzLogic
|
||||
$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);
|
||||
|
||||
$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);
|
||||
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);
|
||||
|
||||
@@ -3,14 +3,10 @@
|
||||
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\Modules\Companies\Services\ListsCompanyModules;
|
||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||
use App\Http\Resources\CompanyModuleResource;
|
||||
use App\Transformers\CompanyTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Company Moduels',
|
||||
'message' => 'You have successfully retrieved a list of Companies'
|
||||
@@ -50,26 +45,15 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListCompanies->passes();
|
||||
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||
use App\Http\Resources\ContactResource;
|
||||
use App\Transformers\ContactTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -64,13 +63,6 @@ class UpdateContactLogic extends AbstractControllerLogic
|
||||
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Http\Resources\DeliveryOrderResource;
|
||||
use App\Models\Order;
|
||||
use App\Transformers\DeliveryOrderTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -53,14 +52,6 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
||||
/** @var Order $order */
|
||||
$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)));
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
$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));
|
||||
|
||||
}
|
||||
|
||||
@@ -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]]));
|
||||
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new DeliveryOrderTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,13 +7,9 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use League\Fractal;
|
||||
|
||||
|
||||
class ListDocumentLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -62,11 +58,6 @@ class ListDocumentLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(DocumentResource::collection($query));
|
||||
|
||||
|
||||
/* return fractal()
|
||||
->collection($query, new DocumentTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Exports\Services;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Order;
|
||||
use App\Models\State;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
@@ -31,8 +32,10 @@ class ExportsWarehousePackingList implements FromQuery, WithHeadings, WithHeadin
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
return Order::whereHas('addresses', function($address) {
|
||||
$address->where('status', ApprovalStatus::APPROVED);
|
||||
$johor_state_id = State::where('name', 'johor')->first()->id;
|
||||
|
||||
return Order::whereHas('addresses', function($address) use ($johor_state_id){
|
||||
$address->where('status', ApprovalStatus::APPROVED)->where('state_id', $johor_state_id);
|
||||
})->whereHas('packingLists', function($packingLists) {
|
||||
$packingLists->where('type', PackingListType::SHIPPING_PACKING_LIST)->whereDoesntHave('transports');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Groups\DataTransferObjects;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GroupObject implements DataTransferObject
|
||||
{
|
||||
|
||||
/** @var int */
|
||||
private $issuer;
|
||||
|
||||
/** @var int */
|
||||
private $receiver;
|
||||
|
||||
/** @var float */
|
||||
private $amount;
|
||||
|
||||
/** @var float */
|
||||
private $originalAmount;
|
||||
|
||||
/** @var int */
|
||||
private $currencyId;
|
||||
|
||||
/** @var int */
|
||||
private $originalCurrencyId;
|
||||
|
||||
/** @var float */
|
||||
private $currencyRate;
|
||||
|
||||
/** @var float */
|
||||
private $tax;
|
||||
|
||||
/** @var float */
|
||||
private $serviceCharge;
|
||||
|
||||
/** @var int|null */
|
||||
private $status;
|
||||
|
||||
/** @var string */
|
||||
private $reference;
|
||||
|
||||
/** @var int */
|
||||
private $paymentMethod;
|
||||
|
||||
/**
|
||||
* GroupObject constructor.
|
||||
* @param int $issuer
|
||||
* @param int $receiver
|
||||
* @param float $amount
|
||||
* @param float $originalAmount
|
||||
* @param int $currencyId
|
||||
* @param int $originalCurrencyId
|
||||
* @param float $currencyRate
|
||||
* @param float $tax
|
||||
* @param float $serviceCharge
|
||||
* @param string $reference
|
||||
* @param int|null $status
|
||||
* @param int $paymentMethod
|
||||
*/
|
||||
public function __construct(
|
||||
int $issuer,
|
||||
int $receiver,
|
||||
float $amount,
|
||||
float $originalAmount,
|
||||
int $currencyId,
|
||||
int $originalCurrencyId,
|
||||
float $currencyRate,
|
||||
float $tax,
|
||||
float $serviceCharge,
|
||||
int $paymentMethod,
|
||||
?string $reference,
|
||||
?int $status = ApprovalStatus::PENDING_SUBMISSION
|
||||
)
|
||||
{
|
||||
$this->issuer = $issuer;
|
||||
$this->receiver = $receiver;
|
||||
$this->amount = $amount;
|
||||
$this->originalAmount = $originalAmount;
|
||||
$this->currencyId = $currencyId;
|
||||
$this->originalCurrencyId = $originalCurrencyId;
|
||||
$this->currencyRate = $currencyRate;
|
||||
$this->tax = $tax;
|
||||
$this->serviceCharge = $serviceCharge;
|
||||
$this->paymentMethod = $paymentMethod;
|
||||
$this->reference = $reference;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getIssuer(): int
|
||||
{
|
||||
return $this->issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getReceiver(): int
|
||||
{
|
||||
return $this->receiver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount(): float
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getOriginalAmount(): float
|
||||
{
|
||||
return $this->originalAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCurrencyId(): int
|
||||
{
|
||||
return $this->currencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOriginalCurrencyId(): int
|
||||
{
|
||||
return $this->originalCurrencyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getCurrencyRate(): float
|
||||
{
|
||||
return $this->currencyRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTax(): float
|
||||
{
|
||||
return $this->tax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getServiceCharge(): float
|
||||
{
|
||||
return $this->serviceCharge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatus(): ?int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReference(): ?string
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPaymentMethod(): int
|
||||
{
|
||||
return $this->paymentMethod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Groups\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Groups\DataTransferObjects\GroupObject;
|
||||
use App\Models\Group;
|
||||
|
||||
class CreatesGroup extends AbstractUpdateRecord
|
||||
{
|
||||
/**
|
||||
* @param GroupObject $object
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(GroupObject $object) {
|
||||
$model = new Group();
|
||||
$model->issuer = $object->getIssuer();
|
||||
$model->receiver = $object->getReceiver();
|
||||
$model->amount = $object->getAmount();
|
||||
$model->original_amount = $object->getOriginalAmount();
|
||||
$model->currency_id = $object->getCurrencyId();
|
||||
$model->original_currency_id = $object->getOriginalCurrencyId();
|
||||
$model->currency_rate = $object->getCurrencyRate();
|
||||
$model->tax = $object->getTax();
|
||||
$model->service_charge = $object->getServiceCharge();
|
||||
$model->status = $object->getStatus();
|
||||
$model->reference = $object->getReference();
|
||||
$model->payment_method = $object->getPaymentMethod();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||
use App\Http\Resources\AddressResource;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Transformers\AddressTransformer;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -40,12 +39,6 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
||||
{
|
||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
||||
|
||||
|
||||
//load address with no relationships
|
||||
/* return fractal()
|
||||
->item($address, new AddressTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new AddressResource($address));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,14 @@ namespace App\Classes\Modules\Orders\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\PerfexCRM\Processors\NewLeadTaskToPerfexCRMProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\CreateOrderProcessor;
|
||||
use App\Classes\Modules\Orders\Services\GeneratesOrderNumber;
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\WarehouseReferences;
|
||||
use App\Http\Resources\OrderResource;
|
||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||
use App\Models\Address;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -47,12 +41,6 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
/** @var GeneratesOrderNumber */
|
||||
private $generatesOrderNumber;
|
||||
|
||||
/** @var CreatesAddress */
|
||||
private $createsAddress;
|
||||
|
||||
/** @var CanCreateAddress */
|
||||
private $canCreateAddress;
|
||||
|
||||
/** @var NewLeadTaskToPerfexCRMProcessor */
|
||||
private $newLeadTaskToPerfexCRMProcessor;
|
||||
/**
|
||||
@@ -63,18 +51,14 @@ class CreateOrderLogic extends AbstractControllerLogic
|
||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||
* @param GeneratesOrderNumber $generatesOrderNumber
|
||||
* @param NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor
|
||||
* @param CreatesAddress $createsAddress
|
||||
* @param CanCreateAddress $canCreateAddress
|
||||
*/
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, CreatesAddress $createsAddress, CanCreateAddress $canCreateAddress, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber, NewLeadTaskToPerfexCRMProcessor $newLeadTaskToPerfexCRMProcessor)
|
||||
{
|
||||
$this->fetchesCompany = $fetchesCompany;
|
||||
$this->fetchesAddress = $fetchesAddress;
|
||||
$this->createOrderProcessor = $createOrderProcessor;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesOrderNumber = $generatesOrderNumber;
|
||||
$this->createsAddress = $createsAddress;
|
||||
$this->canCreateAddress = $canCreateAddress;
|
||||
$this->newLeadTaskToPerfexCRMProcessor = $newLeadTaskToPerfexCRMProcessor;
|
||||
}
|
||||
|
||||
|
||||
-8
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -57,13 +56,6 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
||||
$container->packingLists()->attach($packing_list_item);
|
||||
}
|
||||
|
||||
//only return with packing list relationship
|
||||
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseInclude(['packingLists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
|
||||
+2
-10
@@ -8,7 +8,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,8 +19,7 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -53,16 +51,10 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
||||
|
||||
//no relationships needed
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -71,11 +70,6 @@ class CreateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -8,7 +8,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -19,8 +18,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container Remark',
|
||||
'message' => 'You have successfully created a new Container Remark'
|
||||
@@ -52,7 +50,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -61,12 +59,6 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
||||
|
||||
$this->createRemarkProcessor->execute($container, $object);
|
||||
|
||||
//load with remarks only
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['remarks'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
}
|
||||
|
||||
+17
-25
@@ -17,7 +17,6 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,8 +28,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Container',
|
||||
'message' => 'You have successfully created a new Container'
|
||||
@@ -43,7 +41,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesCompanyModule */
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
@@ -56,12 +54,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
private $createsSchedule;
|
||||
|
||||
public function __construct(
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
CanCreateContainer $canCreateContainer,
|
||||
FetchesPackingList $fetchesPackingList,
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreatesContainer $createsContainer,
|
||||
CreatesTransport $createsTransport,
|
||||
CreatesSchedule $createsSchedule
|
||||
)
|
||||
{
|
||||
$this->canCreateContainer = $canCreateContainer;
|
||||
@@ -79,11 +77,11 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('container_reference'),
|
||||
$request->input('container_number'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('container_type'),
|
||||
ApprovalStatus::APPROVED
|
||||
@@ -94,27 +92,21 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
||||
$container = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
||||
|
||||
$transportObject = new TransportObject(
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
TransportType::LAND, null,
|
||||
$request->input('tracking'),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
$transport = $this->createsTransport->execute($transportObject, $container);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//include transport
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->parseIncludes(['transport'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Container',
|
||||
'message' => 'You have successfully retrieved a Container'
|
||||
@@ -50,18 +48,12 @@ class FetchContainerLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchContainer->passes();
|
||||
|
||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
||||
|
||||
//load with packing lists
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->parseIncludes(['packing_lists'])
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+2
-9
@@ -9,7 +9,6 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,8 +19,7 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -54,16 +52,11 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$query = $this->fetchInboundCustomCleared->execute();
|
||||
|
||||
//no relations required
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+5
-16
@@ -3,14 +3,10 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +17,7 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Containers',
|
||||
'message' => 'You have successfully retrieved a list of Containers'
|
||||
@@ -50,22 +45,16 @@ class ListContainersLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canListContainers->passes();
|
||||
|
||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
||||
|
||||
//load with no filters, a details page to be added to load one with all related data
|
||||
/* return fractal()
|
||||
->collection($query, new ContainerTransformer)
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->collectionResponse(ContainerResource::collection($query));
|
||||
|
||||
}
|
||||
|
||||
+6
-13
@@ -10,7 +10,6 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,8 +20,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Reschedule Container',
|
||||
'message' => 'You have successfully Reschedule Container'
|
||||
@@ -56,7 +54,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
@@ -67,20 +65,15 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
||||
$this->updatesScheduleStatus->execute($old_sechedule, ApprovalStatus::REJECTED);
|
||||
|
||||
$scheduleObject = new ScheduleObject(
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
Carbon::parse($request->input('etd')),
|
||||
Carbon::parse($request->input('eta')),
|
||||
ApprovalStatus::APPROVED
|
||||
);
|
||||
);
|
||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
||||
|
||||
//no relationship
|
||||
/* return fractal()
|
||||
->item($container, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+10
-21
@@ -3,16 +3,12 @@
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
||||
|
||||
|
||||
use App\Classes\Exceptions\AccessForbiddenException;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Exceptions\RequestValidationException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -23,8 +19,7 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Container',
|
||||
'message' => 'You have successfully updated the Container'
|
||||
@@ -57,19 +52,19 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws AccessForbiddenException
|
||||
* @throws MalformedRequestException
|
||||
* @throws RequestValidationException
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
|
||||
$object = new ContainerObject(
|
||||
$request->input('container_reference'),
|
||||
$container->container_number,
|
||||
$request->input('container_type'),
|
||||
$request->input('seal_reference'),
|
||||
$request->input('loading_date'),
|
||||
$container->status,
|
||||
@@ -79,12 +74,6 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->updatesContainer->execute($container, $object);
|
||||
|
||||
//no relationships
|
||||
/*
|
||||
return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($query));
|
||||
|
||||
}
|
||||
|
||||
+2
-11
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Dispatch Date Container',
|
||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||
@@ -51,18 +49,11 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
||||
|
||||
|
||||
//no relationships queried
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+2
-10
@@ -6,7 +6,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Http\Resources\ContainerResource;
|
||||
use App\Transformers\ContainerTransformer;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,8 +17,7 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Updated Drop Date Container',
|
||||
'message' => 'You have successfully updated the Drop Date Container'
|
||||
@@ -51,17 +49,11 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||
$transport = $container->transports()->first();
|
||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($query, new ContainerTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new ContainerResource($container));
|
||||
}
|
||||
|
||||
|
||||
+5
-13
@@ -14,7 +14,6 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
|
||||
use App\Http\Resources\DeliverPackingListResource;
|
||||
use App\Transformers\DeliverPackingListTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -25,8 +24,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created Deliver PackingList',
|
||||
'message' => 'You have successfully created a new Deliver PackingList'
|
||||
@@ -62,7 +60,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
$packing_list_id = $request->input('packing_list_id');
|
||||
@@ -70,9 +68,9 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
$reference_number = $this->generatesPackingListReferenceNumber->execute();
|
||||
|
||||
$packingListObject = new PackingListObject(
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
$reference_number,
|
||||
null,
|
||||
PackingListType::DELIVERY_PACKING_LIST,
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
@@ -84,12 +82,6 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
||||
|
||||
//no relationships required
|
||||
/* return fractal()
|
||||
->item($deliverPackingList, new DeliverPackingListTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
|
||||
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
* @param UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor)
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
)
|
||||
{
|
||||
$this->updatePostcodeSegmentProcessor = $updatePostcodeSegmentProcessor;
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\Notifications\InvoiceIssuedEmail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Meneses\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\Document;
|
||||
|
||||
class CreateCombinedInvoicesLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Shipping Invoice Status',
|
||||
'message' => 'You have successfully updated multiple shipping invoices status'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus;
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* ApprovePaymentVerificationLogic constructor.
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesPackingList $fetchesPackingList, UpdatesTransactionStatus $updatesTransactionStatus, CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$items = $request->input('ids');
|
||||
$invoice_transactions=array();
|
||||
foreach($items as $item){
|
||||
|
||||
$packing_list = $this->fetchesPackingList->execute(['id' => $item['id']]);
|
||||
|
||||
$invoice_transaction = $packing_list->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::PENDING_SUBMISSION])->first();
|
||||
array_push($invoice_transactions, $invoice_transaction);
|
||||
|
||||
// $this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
$transaction_invoice_pdf = LaravelMpdf::loadView('pages.pdfs.shipping_invoices_combined', ['invoice_transactions' => $invoice_transactions]);
|
||||
|
||||
$document_object = new DocumentObject(
|
||||
DocumentType::SHIPPING_INVOICE,
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($transaction_invoice_pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'shipping_invoice'
|
||||
);
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($invoice_transaction, $document_object);
|
||||
|
||||
$this->createsFiles->execute($document, $document_object);
|
||||
$user = $packing_list->owner->companyModule->employees()->first();
|
||||
if(app()->environment(['production'])) {
|
||||
$user->notify(new InvoiceIssuedEmail($user, $packing_list));
|
||||
}
|
||||
|
||||
return $this->response([]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,24 +7,20 @@ use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Groups\DataTransferObjects\GroupObject;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Models\Group;
|
||||
use App\Classes\Modules\Groups\Services\CreatesGroup;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreateWalletTopUpTransactionProcessor;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\GroupTransaction;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
|
||||
class CreateGroupsLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -43,212 +39,141 @@ class CreateGroupsLogic extends AbstractControllerLogic
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
/** @var FetchesCompanyModule */
|
||||
private $fetchesCompanyModule;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
/** @var CreateWalletTopUpTransactionProcessor */
|
||||
private $createWalletTopUpTransactionProcessor;
|
||||
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
/** @var CreatesGroup */
|
||||
private $createsGroup;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
CreatesTransaction $createsTransaction,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
FetchesCompanyModule $fetchesCompanyModule,
|
||||
CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor,
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor,
|
||||
CreatesGroup $createsGroup
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->createWalletTopUpTransactionProcessor = $createWalletTopUpTransactionProcessor;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
$this->createsGroup = $createsGroup;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
$groupPyamentStatus = ApprovalStatus::PENDING_VERIFICATION;
|
||||
|
||||
if (count($invoice_ids) > 1) {
|
||||
dd('more than 1 invoice');
|
||||
// creates group transaction
|
||||
$group = new Group();
|
||||
$invoice_ids = json_decode($request->route('transaction_ids'));
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$issuer = '';
|
||||
$receiver = '';
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = '';
|
||||
$currency_rate = '';
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
|
||||
// todo-new: check why is this not working
|
||||
// $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]);
|
||||
$invoices = Transaction::whereIn('id', $invoice_ids)->get();
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
// todo-new: attach transaction to the group id
|
||||
// create one payment for each, then mark as pending_approval
|
||||
$issuer = $invoice->issuer;
|
||||
$receiver = $invoice->receiver;
|
||||
$amount += $invoice->amount;
|
||||
$original_amount += $invoice->original_amount;
|
||||
$currency_id = $invoice->currency_id;
|
||||
$original_currency_id = $invoice->original_currency_id;
|
||||
$currency_rate = $invoice->currency_rate;
|
||||
$tax += $invoice->tax;
|
||||
$service_charge += $invoice->service_charge;
|
||||
}
|
||||
$companyModuleId = $invoices->first()->receiver;
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->reference = $billNumber;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
$wallet = Wallet::where('owner_id', $companyModuleId)->first();
|
||||
|
||||
$group->save();
|
||||
|
||||
|
||||
// attach payment on group transaction
|
||||
|
||||
// $invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids->first()]);
|
||||
// $amount = $request->input('amount');
|
||||
// $company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$invoice_transaction = $group;
|
||||
$transferDetails = $billNumber;
|
||||
$company_module = $group->receiverCompany;
|
||||
} else {
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $invoice_ids[0]]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
$transferDetails = $invoice_transaction->bill_no;
|
||||
}
|
||||
|
||||
$payment_reference = null;
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $transferDetails,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$request->input('bank_code'),
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
// todo-new: verify currently checking wallet amount based on 'amount' value passed by frontend
|
||||
if((float) number_format(($wallet->amount - $request->input('amount')),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
if (count($invoice_ids) > 1) {
|
||||
// do one by one
|
||||
// dd($invoices);
|
||||
// todo-new: update all the transaction inside
|
||||
} else {
|
||||
// $invoice_transaction;
|
||||
$packingList = $invoice_transaction->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
}
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
$this->updatesTransactionStatus->execute($invoice_transaction, ApprovalStatus::COMPLETED);
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
$groupPyamentStatus = ApprovalStatus::APPROVED;
|
||||
}
|
||||
|
||||
// createsPaymentTransaction
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$issuer = 0;
|
||||
$receiver = 0;
|
||||
$amount = 0;
|
||||
$original_amount = 0;
|
||||
$currency_id = 0;
|
||||
$original_currency_id = 0;
|
||||
$currency_rate = 0;
|
||||
$tax = 0;
|
||||
$service_charge = 0;
|
||||
|
||||
$group = new GroupObject(
|
||||
$issuer,
|
||||
$receiver,
|
||||
$amount,
|
||||
$original_amount,
|
||||
$currency_id,
|
||||
$original_currency_id,
|
||||
$currency_rate,
|
||||
$tax,
|
||||
$service_charge,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
'-',
|
||||
$groupPyamentStatus,
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
$group = $this->createsGroup->execute($group);
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
foreach ($invoices as $invoice) {
|
||||
if ($payment_method == PaymentMethodType::WALLET) {
|
||||
$this->createPaymentTransactionProcessor->execute($invoice, PaymentMethodType::WALLET, $request->input('bank_code'));
|
||||
}
|
||||
|
||||
$issuer = $invoice->issuer;
|
||||
$receiver = $invoice->receiver;
|
||||
$amount += $invoice->amount;
|
||||
$original_amount += $invoice->original_amount;
|
||||
$currency_id = $invoice->currency_id;
|
||||
$original_currency_id = $invoice->original_currency_id;
|
||||
$currency_rate = $invoice->currency_rate;
|
||||
$tax += $invoice->tax;
|
||||
$service_charge += $invoice->service_charge;
|
||||
|
||||
// creates group transaction
|
||||
$groupTransaction = new GroupTransaction();
|
||||
$groupTransaction->group_id = $group->id;
|
||||
$groupTransaction->transaction_id = $invoice->id;
|
||||
$groupTransaction->save();
|
||||
}
|
||||
|
||||
if (in_array($payment_method, [PaymentMethodType::PAYMENT_GATEWAY, PaymentMethodType::CASH])) {
|
||||
// create only one billplz payment for wallet top up
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$companyModuleId = $invoice->receiver;
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $companyModuleId]);
|
||||
|
||||
$topUpTransaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'), true, $payment_method);
|
||||
}
|
||||
|
||||
$group->issuer = $issuer;
|
||||
$group->receiver = $receiver;
|
||||
$group->reference = $payment_method === PaymentMethodType::PAYMENT_GATEWAY ? $topUpTransaction->payment_reference : $billNumber;
|
||||
$group->amount = $amount;
|
||||
$group->original_amount = $original_amount;
|
||||
$group->currency_id = $currency_id;
|
||||
$group->original_currency_id = $original_currency_id;
|
||||
$group->currency_rate = $currency_rate;
|
||||
$group->tax = $tax;
|
||||
$group->service_charge = $service_charge;
|
||||
$group->status = $groupPyamentStatus;
|
||||
$group->save();
|
||||
|
||||
if ($payment_method === PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
return $this->resourceResponse(new WalletTransactionResource($topUpTransaction));
|
||||
|
||||
} else {
|
||||
return $this->response([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-81
@@ -5,30 +5,15 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionDetailObject;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
|
||||
use App\Http\Resources\TransactionResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Mccarlosen\LaravelMpdf\Facades\LaravelMpdf;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
|
||||
class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -42,83 +27,25 @@ class CreatePaymentTransactionLogic extends AbstractControllerLogic
|
||||
/** @var FetchesTransaction */
|
||||
private $fetchesTransaction;
|
||||
|
||||
/** @var FetchesSegmentConstant */
|
||||
private $fetchesSegmentConstant;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionDetail */
|
||||
private $createsTransactionDetail;
|
||||
/** @var CreatePaymentTransactionProcessor */
|
||||
private $createPaymentTransactionProcessor;
|
||||
|
||||
public function __construct(
|
||||
FetchesTransaction $fetchesTransaction,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesTransactionDetail $createsTransactionDetail,
|
||||
CreatesBillplzBill $createsBillplzBill
|
||||
CreatePaymentTransactionProcessor $createPaymentTransactionProcessor
|
||||
)
|
||||
{
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsTransactionDetail = $createsTransactionDetail;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createPaymentTransactionProcessor = $createPaymentTransactionProcessor;
|
||||
}
|
||||
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$payment_method = PaymentMethodType::PAYMENT_METHODS[$request->input('payment_method')];
|
||||
|
||||
$invoice_transaction = $this->fetchesTransaction->execute(['id' => $request->input('transaction_id')]);
|
||||
$amount = $request->input('amount');
|
||||
$company_module = $invoice_transaction->owner()->first()->owner()->first()->companyModule()->first();
|
||||
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
if ($request->input('payment_method') == 5) {
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $invoice_transaction->bill_no,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$request->input('bank_code'),
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$request->input('amount'),
|
||||
$request->input('amount'),
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
ApprovalStatus::PENDING_SUBMISSION,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice_transaction, $object);
|
||||
$payment_transaction = $this->createPaymentTransactionProcessor->execute($invoice_transaction, $payment_method , $request->input('bank_code'));
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($payment_transaction));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -67,11 +66,6 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
$group->delete();
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||
use App\Http\Resources\GroupResource;
|
||||
use App\Transformers\GroupTransformer;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -23,8 +22,7 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Groups',
|
||||
'message' => 'You have successfully retrieved a list of groups'
|
||||
@@ -34,15 +32,10 @@ class ListGroupsLogic extends AbstractControllerLogic
|
||||
/** @var ListsGroups */
|
||||
private $listsGroups;
|
||||
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$query = $this->listsGroups->execute($this->listsGroups->deserializeFilters($request->input('filters')));
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->collection($query, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->collectionResponse(GroupResource::collection($query));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification(): array
|
||||
{
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Update Group Transaction',
|
||||
'message' => 'You have successfully updated this Group Transaction'
|
||||
@@ -87,7 +86,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function logic(Request $request): JsonResponse
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -101,7 +100,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
||||
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
foreach($transactions as $transaction) {
|
||||
|
||||
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||
@@ -170,7 +169,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
|
||||
$object = new DocumentObject(
|
||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
||||
[chunk_split('data:application/pdf;base64,' . base64_encode($pdf->output()))],
|
||||
[chunk_split('data:application/pdf;base64,'.base64_encode($pdf->output()))],
|
||||
'',
|
||||
ApprovalStatus::COMPLETED,
|
||||
'currency_vendor_order'
|
||||
@@ -180,11 +179,6 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
||||
$document = $this->createsDocument->execute($group, $object);
|
||||
$this->createsFile->execute($document, $object);
|
||||
|
||||
//no relationship needed
|
||||
/* return fractal()
|
||||
->item($group, new GroupTransformer())
|
||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||
|
||||
return $this->resourceResponse(new GroupResource($group));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesPaymentTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionDetail;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Services\UpdatesWalletBalance;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
|
||||
class CreatePaymentTransactionProcessor
|
||||
{
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesPaymentTransaction */
|
||||
private $createsPaymentTransaction;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var UpdatesWalletBalance */
|
||||
private $updatesWalletBalance;
|
||||
|
||||
/** @var UpdateDoFromVTPortalProcessor */
|
||||
private $updateDoFromVTPortalProcessor;
|
||||
|
||||
/** @var UpdateDoFromYDPortalProcessor */
|
||||
private $updateDoFromYDPortalProcessor ;
|
||||
|
||||
/** @var UpdatesTransactionStatus */
|
||||
private $updatesTransactionStatus ;
|
||||
|
||||
/**
|
||||
* @param FetchesTransaction $fetchesTransaction,
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
* @param CreatesPaymentTransaction $createsPaymentTransaction
|
||||
* @param CreatesTransactionDetail $createsTransactionDetail
|
||||
* @param CreatesBillplzBill $createsBillplzBil
|
||||
* @param CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
* @param UpdatesWalletBalance $updatesWalletBalance
|
||||
* @param UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor
|
||||
* @param UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesPaymentTransaction $createsPaymentTransaction,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction,
|
||||
UpdatesWalletBalance $updatesWalletBalance,
|
||||
UpdateDoFromVTPortalProcessor $updateDoFromVTPortalProcessor,
|
||||
UpdateDoFromYDPortalProcessor $updateDoFromYDPortalProcessor,
|
||||
UpdatesTransactionStatus $updatesTransactionStatus
|
||||
)
|
||||
{
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsPaymentTransaction = $createsPaymentTransaction;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->updatesWalletBalance = $updatesWalletBalance;
|
||||
$this->updateDoFromVTPortalProcessor = $updateDoFromVTPortalProcessor;
|
||||
$this->updateDoFromYDPortalProcessor = $updateDoFromYDPortalProcessor;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(Transaction $invoice, $payment_method, $bank_code)
|
||||
{
|
||||
$amount = $invoice->amount;
|
||||
$company_module = $invoice->owner()->first()->owner()->first()->companyModule()->first();
|
||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
$payment_reference = null;
|
||||
|
||||
if ($payment_method == PaymentMethodType::PAYMENT_GATEWAY) {
|
||||
|
||||
// create billplz transaction
|
||||
$payment_method = PaymentMethodType::PAYMENT_GATEWAY;
|
||||
$billPlzBill = $this->createsBillplzBill->execute(
|
||||
$company_module->name,
|
||||
(app()->environment(['production'])) ? $company_module->employees()->first()->email : 'uldvstar@gmail.com',
|
||||
'This payment is for the invoice number . ' . $billNumber,
|
||||
$amount,
|
||||
$billNumber,
|
||||
$bank_code,
|
||||
true
|
||||
);
|
||||
|
||||
$payment_reference = $billPlzBill->id;
|
||||
}
|
||||
else if ($payment_method === PaymentMethodType::WALLET) {
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $company_module->wallets()->first();
|
||||
|
||||
if((float) number_format(($wallet->amount - $amount),2) < 0){
|
||||
throw new MalformedRequestException('Insufficient wallet balance. Please Top up your wallet.');
|
||||
}
|
||||
|
||||
$walletPaymentBillNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||
|
||||
$transaction_object = new TransactionObject($walletPaymentBillNumber, TransactionType::PAYMENT, 1, $company_module->id, 1, PaymentMethodType::WALLET, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::APPROVED, [], '');
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
$payment_reference = $walletPaymentBillNumber;
|
||||
|
||||
$this->updatesWalletBalance->execute($wallet, ($amount * -1));
|
||||
|
||||
$packingList = $invoice->owner;
|
||||
$order = $packingList->owner;
|
||||
$packingList->status = ApprovalStatus::APPROVED;
|
||||
$packingList->save();
|
||||
|
||||
if(app()->environment('production')){
|
||||
$this->updateDoFromVTPortalProcessor->execute($packingList);
|
||||
$this->updateDoFromYDPortalProcessor->execute($packingList);
|
||||
}
|
||||
|
||||
// later use this variabke to create a approved payment transaction
|
||||
$approvalStatus = ApprovalStatus::APPROVED;
|
||||
|
||||
// update invoice to completed
|
||||
$this->updatesTransactionStatus->execute($invoice, ApprovalStatus::COMPLETED);
|
||||
|
||||
}
|
||||
else {
|
||||
$payment_method = PaymentMethodType::CASH;
|
||||
}
|
||||
|
||||
$object = new TransactionObject(
|
||||
$billNumber,
|
||||
TransactionType::PAYMENT,
|
||||
$company_module->id,
|
||||
1,
|
||||
1,
|
||||
$payment_method,
|
||||
$amount,
|
||||
$amount,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
$approvalStatus,
|
||||
null,
|
||||
$payment_reference
|
||||
);
|
||||
|
||||
$payment_transaction = $this->createsPaymentTransaction->execute($invoice, $object);
|
||||
|
||||
return $payment_transaction;
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,15 @@
|
||||
|
||||
namespace App\Classes\Modules\Wallets\ControllersLogic;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\Modules\Wallets\Processors\CreateWalletTopUpTransactionProcessor;
|
||||
use App\Http\Resources\WalletTransactionResource;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -52,6 +46,9 @@ class TopUpWalletLogic extends AbstractControllerLogic
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/** @var CreateWalletTopUpTransactionProcessor */
|
||||
private $createWalletTopUpTransactionProcessor;
|
||||
|
||||
|
||||
/**
|
||||
* TopUpWalletLogic constructor.
|
||||
@@ -61,8 +58,9 @@ class TopUpWalletLogic extends AbstractControllerLogic
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor
|
||||
*/
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransactionableTransaction $createsTransactionableTransaction)
|
||||
public function __construct(FetchesCompanyModule $fetchesCompanyModule, GeneratesWalletCode $generatesWalletCode, CreatesWallet $createsWallet, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesBillplzBill $createsBillplzBill, CreatesTransactionableTransaction $createsTransactionableTransaction, CreateWalletTopUpTransactionProcessor $createWalletTopUpTransactionProcessor)
|
||||
{
|
||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
@@ -70,6 +68,7 @@ class TopUpWalletLogic extends AbstractControllerLogic
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
$this->createWalletTopUpTransactionProcessor = $createWalletTopUpTransactionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,27 +81,7 @@ class TopUpWalletLogic extends AbstractControllerLogic
|
||||
$amount = floatval(str_replace(',', '', $request->input('amount')));
|
||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $companyModule);
|
||||
}
|
||||
|
||||
$user = $companyModule->employees()->first();
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
|
||||
|
||||
if($amount < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
|
||||
$billPlzBill = $this->createsBillplzBill->execute($companyModule->name, $user->email, 'This payment is credit topup for company ref. ' . $companyModule->reference, $amount, $billNumber, $request->input('bank_code'), true);
|
||||
|
||||
$transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
$transaction = $this->createWalletTopUpTransactionProcessor->execute($companyModule, $amount, $request->input('bank_code'));
|
||||
|
||||
return $this->resourceResponse(new WalletTransactionResource($transaction));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Wallets\Processors;
|
||||
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Wallets\Services\CreatesWallet;
|
||||
use App\Classes\Modules\Wallets\Services\GeneratesWalletCode;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Billplzs\Services\CreatesBillplzBill;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransactionableTransaction;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\Wallet;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
|
||||
|
||||
class CreateWalletTopUpTransactionProcessor
|
||||
{
|
||||
/** @var GeneratesWalletCode */
|
||||
private $generatesWalletCode;
|
||||
|
||||
/** @var CreatesWallet */
|
||||
private $createsWallet;
|
||||
|
||||
/** @var GeneratesTransactionBillNumber */
|
||||
private $generatesTransactionBillNumber;
|
||||
|
||||
/** @var CreatesBillplzBill */
|
||||
private $createsBillplzBill;
|
||||
|
||||
/** @var CreatesTransactionableTransaction */
|
||||
private $createsTransactionableTransaction;
|
||||
|
||||
/**
|
||||
* @param GeneratesWalletCode $generatesWalletCode
|
||||
* @param CreatesWallet $createsWallet
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesBillplzBill $createsBillplzBill
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
*/
|
||||
public function __construct(
|
||||
GeneratesWalletCode $generatesWalletCode,
|
||||
CreatesWallet $createsWallet,
|
||||
GeneratesTransactionBillNumber $generatesTransactionBillNumber,
|
||||
CreatesBillplzBill $createsBillplzBill,
|
||||
CreatesTransactionableTransaction $createsTransactionableTransaction
|
||||
)
|
||||
{
|
||||
$this->generatesWalletCode = $generatesWalletCode;
|
||||
$this->createsWallet = $createsWallet;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsBillplzBill = $createsBillplzBill;
|
||||
$this->createsTransactionableTransaction = $createsTransactionableTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(CompanyModule $companyModule, $amount, $bank_code, ?bool $groupTransaction = false)
|
||||
{
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $companyModule->wallets()->first();
|
||||
|
||||
if (!$wallet) {
|
||||
$object = new WalletObject($companyModule->id, 1, $this->generatesWalletCode->execute());
|
||||
/** @var Wallet $wallet */
|
||||
$wallet = $this->createsWallet->execute($object, $companyModule);
|
||||
}
|
||||
|
||||
$user = $companyModule->employees()->first();
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('TOPUP-');
|
||||
|
||||
if($amount < 0) {
|
||||
throw new MalformedRequestException('Top up credit value must be greater than zero.');
|
||||
}
|
||||
|
||||
$billPlzBill = $this->createsBillplzBill->execute($companyModule->name, $user->email, 'This payment is credit topup for company ref. ' . $companyModule->reference, $amount, $billNumber, $bank_code, true);
|
||||
|
||||
// IF $groupTransaction, transaction type is GROUP_PAYMENT
|
||||
$transaction_object = new TransactionObject($billNumber, $groupTransaction? TransactionType::GROUP_PAYMENT: TransactionType::TOP_UP, 1, $companyModule->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $amount, $amount, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], $billPlzBill->id);
|
||||
|
||||
$transaction = $this->createsTransactionableTransaction->execute($wallet, $transaction_object);
|
||||
|
||||
return $transaction;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class RouteType {
|
||||
|
||||
public const WEB = 1;
|
||||
|
||||
public const API = 2;
|
||||
|
||||
}
|
||||
@@ -4,15 +4,12 @@ namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class TransactionType {
|
||||
|
||||
// public const PAYMENT_ATTEMPT = 0;
|
||||
|
||||
public const SHIPPING_INVOICE = 1;
|
||||
|
||||
public const PAYMENT = 2;
|
||||
|
||||
// public const PAYMENT_ATTEMPT = 0;
|
||||
|
||||
|
||||
// public const INVOICE = 2;
|
||||
|
||||
// public const BILL = 3;
|
||||
|
||||
// public const PERFORMA = 4;
|
||||
@@ -36,6 +33,9 @@ final class TransactionType {
|
||||
public const CASH_BACK = 13;
|
||||
|
||||
// public const SHIPPING_COST = 14;
|
||||
|
||||
public const GROUP_PAYMENT = 15;
|
||||
|
||||
public const TRANSACTION_TYPE_ID = [
|
||||
self::SHIPPING_INVOICE => "Shipping Invoice",
|
||||
self::PAYMENT => "Payment",
|
||||
|
||||
+12
-17
@@ -28,31 +28,26 @@ class Kernel extends ConsoleKernel
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
|
||||
// $schedule->command('command:curlVTCommand')
|
||||
// ->cron('0 8 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
$schedule->command('command:curlVTCommand')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('30 9-18/3 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('0 9 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
||||
|
||||
$schedule->command('approve:invoice')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/approve_invoice.log');
|
||||
|
||||
$schedule->command('billplz-failed-callback:fix')
|
||||
->dailyAt('00:00')
|
||||
->withoutOverlapping()
|
||||
|
||||
@@ -19,39 +19,7 @@ use Illuminate\Http\Request;
|
||||
|
||||
class MonthlyReportController
|
||||
{
|
||||
|
||||
/**
|
||||
* Get Containers
|
||||
* @param $from
|
||||
* @param $to
|
||||
* @return mixed
|
||||
*/
|
||||
private function getContainersByLoadingDate($from, $to)
|
||||
{
|
||||
return Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
}
|
||||
|
||||
private function getPackages($from, $to)
|
||||
{
|
||||
|
||||
$containers = $this->getContainersByLoadingDate($from, $to);
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
return $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function salesReport(Request $request): JsonResponse
|
||||
{
|
||||
public function salesReport(Request $request): JsonResponse {
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
||||
|
||||
@@ -71,18 +39,16 @@ class MonthlyReportController
|
||||
return $container->orders;
|
||||
})->unique();
|
||||
|
||||
$packages = $this->getPackages($from, $to);
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
/* $packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
||||
@@ -123,18 +89,19 @@ class MonthlyReportController
|
||||
$model = (int) $request->route('model');
|
||||
$value = (float) $request->route('value');
|
||||
|
||||
$packages = $this->getPackages($from, $to);
|
||||
|
||||
/* $packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
|
||||
$totalCbm = $packages->sum(function($package){
|
||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
||||
@@ -175,20 +142,18 @@ class MonthlyReportController
|
||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::parse('01-01-2018');
|
||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
|
||||
|
||||
/* $containers = $this->getContainersByLoadingDate($from, $to);
|
||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
$packingLists = $containers->flatMap(function ($container) {
|
||||
return $container->packingLists;
|
||||
});
|
||||
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});*/
|
||||
|
||||
$packages = $this->getPackages($from, $to);
|
||||
$packages = $packingLists->map(function ($packingList) {
|
||||
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
|
||||
return $replica ? $replica : $packingList;
|
||||
})->flatMap(function ($packingList) {
|
||||
return $packingList->packages;
|
||||
});
|
||||
|
||||
$packages = $packages->filter(function($package) use ($id) {
|
||||
return $package->companyModule->id === $id;
|
||||
@@ -245,19 +210,17 @@ class MonthlyReportController
|
||||
$minCbm = $request->input('cbm');
|
||||
$minOrders = $request->input('minOrders');
|
||||
|
||||
/* $activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
$activeCompanies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', \Carbon\Carbon::parse($inactive_start))->where('drop_date', '<=', \Carbon\Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
$companies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();*/
|
||||
|
||||
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||
$companies = CompanyModule::where('type', \App\Classes\ValueObjects\Constants\BusinessType::IMPORTER)->whereHas('orderPackingLists', function($query) use($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', \Carbon\Carbon::parse($active_start))->whereDate('drop_date', '<=', \Carbon\Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();
|
||||
|
||||
$customerActivityData = [];
|
||||
$counter = 1;
|
||||
@@ -277,7 +240,7 @@ class MonthlyReportController
|
||||
if ($minOrders != 'null' && $packingList->count() < $minOrders) { continue; }
|
||||
|
||||
array_push($customerActivityData, array(
|
||||
'key' => $counter,
|
||||
'key' => $counter,
|
||||
'marking' => $marking,
|
||||
'packingListCount'=> $packingList->count(),
|
||||
'totalCbm'=> $totalCbm,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\CreateCombinedInvoicesLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateCombinedInvoicesController
|
||||
{
|
||||
|
||||
public function combine(Request $request, CreateCombinedInvoicesLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -38,13 +38,11 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
// \App\Http\Middleware\WebRouteLogs::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:300,1',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
// \App\Http\Middleware\ApiRouteLogs::class,
|
||||
],
|
||||
|
||||
'apipub' => [
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\RouteLog;
|
||||
use App\Classes\ValueObjects\Constants\RouteType;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ApiRouteLogs
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$ip_address = getenv('REMOTE_ADDR') == '::1' ? '127.0.0.1' : getenv('REMOTE_ADDR');
|
||||
$url = urldecode($request->fullUrl());
|
||||
$request_method = $request->method();
|
||||
$platform = $request->header('sec-ch-ua-platform');
|
||||
$browser = Str::after($request->header('sec-ch-ua'), 'Not?A_Brand";v="8", "Chromium";v="108", "');
|
||||
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip_address"));
|
||||
$longitude = $geo["geoplugin_longitude"];
|
||||
$latitude = $geo["geoplugin_latitude"];
|
||||
$last_page = url()->previous();
|
||||
$countryName = $geo["geoplugin_countryName"];
|
||||
|
||||
$user_id = Auth::user() ? Auth::user()->id : 0;
|
||||
|
||||
// if ($user_id != 0) {
|
||||
// // $ip_address
|
||||
// $webRouteLogWithSameIp = RouteLog::where('ip_address', $ip_address)->where('user_id', 0)->get();
|
||||
// dd($webRouteLogWithSameIp);
|
||||
// foreach($webRouteLogWithSameIp as $result){
|
||||
// $result
|
||||
// }
|
||||
// }
|
||||
|
||||
$route_log = [
|
||||
'user_id' => $user_id,
|
||||
// 'ip_address' => $request->ip(),
|
||||
'ip_address' => $ip_address,
|
||||
'url' => $url,
|
||||
'request_method' => $request_method,
|
||||
'browser' => $browser,
|
||||
'platform' => $platform,
|
||||
'longitude' => $longitude,
|
||||
'latitude' => $latitude,
|
||||
'last_page' => $last_page,
|
||||
'countryname' => $countryName,
|
||||
'route_type' => RouteType::API,
|
||||
];
|
||||
|
||||
RouteLog::create($route_log);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\RouteLog;
|
||||
use App\Classes\ValueObjects\Constants\RouteType;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class WebRouteLogs
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$ip_address = getenv('REMOTE_ADDR') == '::1' ? '127.0.0.1' : getenv('REMOTE_ADDR');
|
||||
$url = $request->fullUrl();
|
||||
$request_method = $request->method();
|
||||
$platform = $request->header('sec-ch-ua-platform');
|
||||
$browser = Str::after($request->header('sec-ch-ua'), 'Not?A_Brand";v="8", "Chromium";v="108", "');
|
||||
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$ip_address"));
|
||||
$longitude = $geo["geoplugin_longitude"];
|
||||
$latitude = $geo["geoplugin_latitude"];
|
||||
$last_page = url()->previous();
|
||||
$countryName = $geo["geoplugin_countryName"];
|
||||
|
||||
$route_log = [
|
||||
'user_id' => Auth::user() ? Auth::user()->id : 0,
|
||||
// 'ip_address' => $request->ip(),
|
||||
'ip_address' => $ip_address,
|
||||
'url' => $url,
|
||||
'request_method' => $request_method,
|
||||
'browser' => $browser,
|
||||
'platform' => $platform,
|
||||
'longitude' => $longitude,
|
||||
'latitude' => $latitude,
|
||||
'last_page' => $last_page,
|
||||
'countryname' => $countryName,
|
||||
'route_type' => RouteType::WEB,
|
||||
];
|
||||
|
||||
// dd($route_log);
|
||||
|
||||
RouteLog::create($route_log);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AirShipmentItemPriceResource extends JsonResource
|
||||
@@ -10,10 +9,10 @@ class AirShipmentItemPriceResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request): array
|
||||
public function toArray($request)
|
||||
{
|
||||
$object = $this->resource;
|
||||
$detailsArray = (array)json_decode($object['details']);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -11,10 +10,10 @@ class AnnouncementResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request): array
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BankResource extends JsonResource
|
||||
@@ -10,10 +9,10 @@ class BankResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request): array
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/*todo delete this*/
|
||||
class BookingResource extends JsonResource
|
||||
{
|
||||
|
||||
|
||||
@@ -28,16 +28,4 @@ class DocumentResource extends JsonResource
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* include only when should include file, to be loaded if needed in the UI
|
||||
* @param bool $includeFile
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldIncludeFiles(bool $includeFile): bool
|
||||
{
|
||||
return $includeFile;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Transaction;
|
||||
use App\Classes\ValueObjects\Constants\PaymentMethodType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class GroupResource extends JsonResource
|
||||
@@ -22,9 +18,8 @@ class GroupResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
if(!$this->issuerCompany){
|
||||
dd($this->id);
|
||||
}
|
||||
// dd($this->groupTransactions);
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'original_amount' => (float) $this->original_amount,
|
||||
@@ -36,18 +31,12 @@ class GroupResource extends JsonResource
|
||||
'currency' => new CurrencyResource($this->currency),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A'),
|
||||
'currency_rate' => (float) $this->currency_rate,
|
||||
'transactions' => $this->transactions()->get()->pluck('owner.owner.marking'),
|
||||
'complete_transactions' => $this->transactions()->whereHasMorph('owner', [Transaction::class], function($query){
|
||||
return $query->whereHas('booking', function($query){
|
||||
return $query->whereHas('transactions', function($query){
|
||||
return $query->where('type', TransactionType::PURCHASE_ORDER)->where('status', '=', ApprovalStatus::APPROVED);
|
||||
});
|
||||
});
|
||||
})->get()->pluck('owner.owner.marking'),
|
||||
'documents' => [
|
||||
'currency_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::CURRENCY_VENDOR_ORDER)->first()),
|
||||
'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::BULK_PURCHASE_ORDER)->first())
|
||||
]
|
||||
'status' => $this->status,
|
||||
'status_name' => ApprovalStatus::APPROVAL_STATUS_ID[$this->status],
|
||||
'payment_method' => $this->payment_method,
|
||||
'payment_method_name' => ucwords(PaymentMethodType::PAYMENT_METHODS_ID[$this->payment_method]),
|
||||
'invoices' => GroupTransactionResource::collection($this->groupTransactions),
|
||||
'reference' => $this->reference,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Order;
|
||||
use App\Models\Transaction;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class GroupTransactionResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return new TransactionResource($this->transaction);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
//global helpers functions here
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Get Active companies
|
||||
* TODO add extract BusinessType::IMPORTER to a $businessType parameter
|
||||
* @param $inactive_start
|
||||
* @param $inactive_end
|
||||
* @param $active_start
|
||||
* @param $active_end
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
if (!function_exists('getActiveCompanies')) {
|
||||
function getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end)
|
||||
{
|
||||
$activeCompanies = CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($inactive_start, $inactive_end) {
|
||||
return $query->where('drop_date', '>=', Carbon::parse($inactive_start))->where('drop_date', '<=', Carbon::parse($inactive_end)->addDay());
|
||||
});
|
||||
})->pluck('id');
|
||||
|
||||
return CompanyModule::where('type', BusinessType::IMPORTER)->whereHas('orderPackingLists', function ($query) use ($active_start, $active_end) {
|
||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||
});
|
||||
})->whereNotIn('id', $activeCompanies)->get();
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Get Packing List
|
||||
* TODO change all packing related query to this
|
||||
* @param Company $company
|
||||
* @return mixed
|
||||
*/
|
||||
if (!function_exists('getPackingList')) {
|
||||
function getPackingList(Company $company)
|
||||
{
|
||||
return $company->orderPackingLists()->where('packing_lists.type', PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-55
@@ -4,22 +4,16 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class Address
|
||||
*
|
||||
* @package App\Models
|
||||
*
|
||||
* @property int country_id
|
||||
* @property int company_id
|
||||
* @property int state_id
|
||||
@@ -28,53 +22,6 @@ use Spatie\Activitylog\Models\Activity;
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property string|null $reference
|
||||
* @property int $type
|
||||
* @property int $default
|
||||
* @property int $status
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Collection|Contact[] $contacts
|
||||
* @property-read int|null $contacts_count
|
||||
* @property-read Country|null $country
|
||||
* @property-read District|null $district
|
||||
* @property-read Model|Eloquent $owner
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read State|null $state
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @method static Builder|Address defaultAddress()
|
||||
* @method static Builder|Address newModelQuery()
|
||||
* @method static Builder|Address newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Address onlyTrashed()
|
||||
* @method static Builder|Address query()
|
||||
* @method static Builder|Address whereCountryId($value)
|
||||
* @method static Builder|Address whereCreatedAt($value)
|
||||
* @method static Builder|Address whereDefault($value)
|
||||
* @method static Builder|Address whereDeletedAt($value)
|
||||
* @method static Builder|Address whereDistrictId($value)
|
||||
* @method static Builder|Address whereId($value)
|
||||
* @method static Builder|Address whereOwnerId($value)
|
||||
* @method static Builder|Address whereOwnerType($value)
|
||||
* @method static Builder|Address wherePostcode($value)
|
||||
* @method static Builder|Address whereReference($value)
|
||||
* @method static Builder|Address whereStateId($value)
|
||||
* @method static Builder|Address whereStatus($value)
|
||||
* @method static Builder|Address whereStreetOne($value)
|
||||
* @method static Builder|Address whereStreetTwo($value)
|
||||
* @method static Builder|Address whereType($value)
|
||||
* @method static Builder|Address whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Address withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Address withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Address extends AbstractModel implements Contactable, Remarkable
|
||||
{
|
||||
@@ -111,7 +58,7 @@ class Address extends AbstractModel implements Contactable, Remarkable
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphTo
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
|
||||
@@ -2,56 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class Announcement
|
||||
*
|
||||
* @package App\Models
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property string|null $starting_on
|
||||
* @property string|null $ending_on
|
||||
* @property int $is_all_day
|
||||
* @property int $duration
|
||||
* @property int $is_recurring
|
||||
* @property string|null $recurrence_pattern
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Collection|Segment[] $segments
|
||||
* @property-read int|null $segments_count
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|Announcement newModelQuery()
|
||||
* @method static Builder|Announcement newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Announcement onlyTrashed()
|
||||
* @method static Builder|Announcement query()
|
||||
* @method static Builder|Announcement whereCreatedAt($value)
|
||||
* @method static Builder|Announcement whereDeletedAt($value)
|
||||
* @method static Builder|Announcement whereDescription($value)
|
||||
* @method static Builder|Announcement whereDuration($value)
|
||||
* @method static Builder|Announcement whereEndingOn($value)
|
||||
* @method static Builder|Announcement whereId($value)
|
||||
* @method static Builder|Announcement whereIsAllDay($value)
|
||||
* @method static Builder|Announcement whereIsRecurring($value)
|
||||
* @method static Builder|Announcement whereRecurrencePattern($value)
|
||||
* @method static Builder|Announcement whereStartingOn($value)
|
||||
* @method static Builder|Announcement whereTitle($value)
|
||||
* @method static Builder|Announcement whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Announcement withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Announcement withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*
|
||||
*/
|
||||
class Announcement extends AbstractModel
|
||||
{
|
||||
@@ -60,7 +17,7 @@ class Announcement extends AbstractModel
|
||||
protected $table = 'announcements';
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
**/
|
||||
public function segments(): BelongsToMany
|
||||
{
|
||||
|
||||
@@ -3,64 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* App\Models\BankAccount
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property int $country_id
|
||||
* @property string $bank_name
|
||||
* @property string|null $bank_branch
|
||||
* @property string $account_name
|
||||
* @property string $account_number
|
||||
* @property int $type
|
||||
* @property int $default
|
||||
* @property int $status
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Country|null $country
|
||||
* @property-read Model|\Eloquent $owner
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|BankAccount newModelQuery()
|
||||
* @method static Builder|BankAccount newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|BankAccount onlyTrashed()
|
||||
* @method static Builder|BankAccount query()
|
||||
* @method static Builder|BankAccount whereAccountName($value)
|
||||
* @method static Builder|BankAccount whereAccountNumber($value)
|
||||
* @method static Builder|BankAccount whereBankBranch($value)
|
||||
* @method static Builder|BankAccount whereBankName($value)
|
||||
* @method static Builder|BankAccount whereCountryId($value)
|
||||
* @method static Builder|BankAccount whereCreatedAt($value)
|
||||
* @method static Builder|BankAccount whereDefault($value)
|
||||
* @method static Builder|BankAccount whereDeletedAt($value)
|
||||
* @method static Builder|BankAccount whereId($value)
|
||||
* @method static Builder|BankAccount whereOwnerId($value)
|
||||
* @method static Builder|BankAccount whereOwnerType($value)
|
||||
* @method static Builder|BankAccount whereStatus($value)
|
||||
* @method static Builder|BankAccount whereType($value)
|
||||
* @method static Builder|BankAccount whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|BankAccount withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|BankAccount withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class BankAccount extends AbstractModel implements DataTransferObject
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
+4
-52
@@ -5,72 +5,24 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use App\Classes\General\Interfaces\Contactable;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* Class Company
|
||||
*
|
||||
* @package App\Models
|
||||
* @property Country country_id
|
||||
* @property State state_id
|
||||
* @property District district_id
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property \App\Models\District district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $reference
|
||||
* @property string|null $debtor
|
||||
* @property int $type
|
||||
* @property int $status
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Collection|Address[] $addresses
|
||||
* @property-read int|null $addresses_count
|
||||
* @property-read Collection|BankAccount[] $banks
|
||||
* @property-read int|null $banks_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Collection|CompanyModule[] $companyModules
|
||||
* @property-read int|null $company_modules_count
|
||||
* @property-read Collection|Contact[] $contacts
|
||||
* @property-read int|null $contacts_count
|
||||
* @property-read Collection|Document[] $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read Collection|User[] $employees
|
||||
* @property-read int|null $employees_count
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @method static Builder|Company newModelQuery()
|
||||
* @method static Builder|Company newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Company onlyTrashed()
|
||||
* @method static Builder|Company query()
|
||||
* @method static Builder|Company whereCreatedAt($value)
|
||||
* @method static Builder|Company whereDebtor($value)
|
||||
* @method static Builder|Company whereDeletedAt($value)
|
||||
* @method static Builder|Company whereId($value)
|
||||
* @method static Builder|Company whereName($value)
|
||||
* @method static Builder|Company whereReference($value)
|
||||
* @method static Builder|Company whereStatus($value)
|
||||
* @method static Builder|Company whereType($value)
|
||||
* @method static Builder|Company whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Company withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Company withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Company extends AbstractModel implements Documentable, Contactable
|
||||
{
|
||||
|
||||
@@ -10,9 +10,7 @@ use App\Classes\General\Interfaces\Packable;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -22,83 +20,18 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PhpParser\Node\Expr\AssignOp\Mod;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
|
||||
/**
|
||||
* Class CompanyModule
|
||||
*
|
||||
* @package App\Models
|
||||
* @property Company company_id
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property integer type
|
||||
* @property integer status
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $reference
|
||||
* @property string $unity_hash_id
|
||||
* @property string $unity_signature
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Collection|Address[] $addresses
|
||||
* @property-read int|null $addresses_count
|
||||
* @property-read Collection|BankAccount[] $banks
|
||||
* @property-read int|null $banks_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Company $company
|
||||
* @property-read Collection|CompanyConnection[] $connections
|
||||
* @property-read int|null $connections_count
|
||||
* @property-read Collection|Contact[] $contacts
|
||||
* @property-read int|null $contacts_count
|
||||
* @property-read Collection|Container[] $containers
|
||||
* @property-read int|null $containers_count
|
||||
* @property-read Collection|Document[] $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read Collection|User[] $employees
|
||||
* @property-read int|null $employees_count
|
||||
* @property-read Collection|CompanyModule[] $inviters
|
||||
* @property-read int|null $inviters_count
|
||||
* @property-read Collection|CompanyModule[] $invites
|
||||
* @property-read int|null $invites_count
|
||||
* @property-read Collection|Order[] $orders
|
||||
* @property-read int|null $orders_count
|
||||
* @property-read Collection|PackingList[] $packingLists
|
||||
* @property-read int|null $packing_lists_count
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Collection|Segment[] $segments
|
||||
* @property-read int|null $segments_count
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @property-read Collection|Wallet[] $wallets
|
||||
* @property-read int|null $wallets_count
|
||||
* @method static Builder|CompanyModule freightForwarders()
|
||||
* @method static Builder|CompanyModule importers()
|
||||
* @method static Builder|CompanyModule newModelQuery()
|
||||
* @method static Builder|CompanyModule newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|CompanyModule onlyTrashed()
|
||||
* @method static Builder|CompanyModule query()
|
||||
* @method static Builder|CompanyModule warehouses()
|
||||
* @method static Builder|CompanyModule whereCompanyId($value)
|
||||
* @method static Builder|CompanyModule whereCreatedAt($value)
|
||||
* @method static Builder|CompanyModule whereDeletedAt($value)
|
||||
* @method static Builder|CompanyModule whereId($value)
|
||||
* @method static Builder|CompanyModule whereName($value)
|
||||
* @method static Builder|CompanyModule whereReference($value)
|
||||
* @method static Builder|CompanyModule whereStatus($value)
|
||||
* @method static Builder|CompanyModule whereType($value)
|
||||
* @method static Builder|CompanyModule whereUnityHashId($value)
|
||||
* @method static Builder|CompanyModule whereUnitySignature($value)
|
||||
* @method static Builder|CompanyModule whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|CompanyModule withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|CompanyModule withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner, Packable, Remarkable
|
||||
{
|
||||
|
||||
+1
-34
@@ -2,18 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class Contact
|
||||
*
|
||||
* @package App\Models
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property string owner_type
|
||||
* @property string reference
|
||||
@@ -21,34 +16,6 @@ use Spatie\Activitylog\Models\Activity;
|
||||
* @property string email
|
||||
* @property string wechat_id
|
||||
* @property int default
|
||||
* @property int $id
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Model|\Eloquent $owner
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|Contact newModelQuery()
|
||||
* @method static Builder|Contact newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Contact onlyTrashed()
|
||||
* @method static Builder|Contact query()
|
||||
* @method static Builder|Contact whereCreatedAt($value)
|
||||
* @method static Builder|Contact whereDefault($value)
|
||||
* @method static Builder|Contact whereDeletedAt($value)
|
||||
* @method static Builder|Contact whereEmail($value)
|
||||
* @method static Builder|Contact whereId($value)
|
||||
* @method static Builder|Contact whereOwnerId($value)
|
||||
* @method static Builder|Contact whereOwnerType($value)
|
||||
* @method static Builder|Contact wherePhone($value)
|
||||
* @method static Builder|Contact whereReference($value)
|
||||
* @method static Builder|Contact whereUpdatedAt($value)
|
||||
* @method static Builder|Contact whereWechatId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Contact withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Contact withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Contact extends AbstractModel
|
||||
{
|
||||
|
||||
@@ -5,63 +5,12 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Remarkable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* App\Models\Container
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property string $reference
|
||||
* @property string|null $container_number
|
||||
* @property int $container_type
|
||||
* @property string|null $seal_reference
|
||||
* @property Carbon|null $loading_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Collection|PackingList[] $packingLists
|
||||
* @property-read int|null $packing_lists_count
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @property-read Collection|\App\Models\Transport[] $transports
|
||||
* @property-read int|null $transports_count
|
||||
* @method static Builder|Container newModelQuery()
|
||||
* @method static Builder|Container newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Container onlyTrashed()
|
||||
* @method static Builder|Container query()
|
||||
* @method static Builder|Container whereContainerNumber($value)
|
||||
* @method static Builder|Container whereContainerType($value)
|
||||
* @method static Builder|Container whereCreatedAt($value)
|
||||
* @method static Builder|Container whereDeletedAt($value)
|
||||
* @method static Builder|Container whereId($value)
|
||||
* @method static Builder|Container whereLoadingDate($value)
|
||||
* @method static Builder|Container whereOwnerId($value)
|
||||
* @method static Builder|Container whereOwnerType($value)
|
||||
* @method static Builder|Container whereReference($value)
|
||||
* @method static Builder|Container whereSealReference($value)
|
||||
* @method static Builder|Container whereStatus($value)
|
||||
* @method static Builder|Container whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Container withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Container withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Container extends AbstractModel implements Transportable, Remarkable
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
+2
-34
@@ -2,52 +2,20 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class Currency
|
||||
*
|
||||
* @package App\Models
|
||||
* @property Country country_id
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property string name
|
||||
* @property string short_code
|
||||
* @property string symbol
|
||||
* @property int $id
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Country|null $country
|
||||
* @property-read Collection|CurrencyRate[] $rates
|
||||
* @property-read int|null $rates_count
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|Currency newModelQuery()
|
||||
* @method static Builder|Currency newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Currency onlyTrashed()
|
||||
* @method static Builder|Currency query()
|
||||
* @method static Builder|Currency whereCountryId($value)
|
||||
* @method static Builder|Currency whereCreatedAt($value)
|
||||
* @method static Builder|Currency whereDeletedAt($value)
|
||||
* @method static Builder|Currency whereId($value)
|
||||
* @method static Builder|Currency whereName($value)
|
||||
* @method static Builder|Currency whereShortCode($value)
|
||||
* @method static Builder|Currency whereSymbol($value)
|
||||
* @method static Builder|Currency whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Currency withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Currency withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
||||
class Currency extends AbstractModel
|
||||
|
||||
+2
-39
@@ -3,21 +3,17 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Traits\Timestamp;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property int owner_type
|
||||
* @property int document_type
|
||||
@@ -27,39 +23,6 @@ use Spatie\Activitylog\Models\Activity;
|
||||
* @property timestamp issued_date
|
||||
* @property timestamp expired_date
|
||||
* @property timestamp approved_date
|
||||
* @property int $id
|
||||
* @property string|null $approval_date
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Collection|File[] $files
|
||||
* @property-read int|null $files_count
|
||||
* @property-read Model|\Eloquent $owner
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|Document newModelQuery()
|
||||
* @method static Builder|Document newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Document onlyTrashed()
|
||||
* @method static Builder|Document query()
|
||||
* @method static Builder|Document whereApprovalDate($value)
|
||||
* @method static Builder|Document whereApprover($value)
|
||||
* @method static Builder|Document whereCreatedAt($value)
|
||||
* @method static Builder|Document whereDeletedAt($value)
|
||||
* @method static Builder|Document whereDocumentType($value)
|
||||
* @method static Builder|Document whereExpiredDate($value)
|
||||
* @method static Builder|Document whereId($value)
|
||||
* @method static Builder|Document whereIssuedDate($value)
|
||||
* @method static Builder|Document whereOwnerId($value)
|
||||
* @method static Builder|Document whereOwnerType($value)
|
||||
* @method static Builder|Document whereReference($value)
|
||||
* @method static Builder|Document whereStatus($value)
|
||||
* @method static Builder|Document whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Document withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Document withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
@@ -80,7 +43,7 @@ class Document extends AbstractModel
|
||||
/**
|
||||
* @return hasMany
|
||||
*/
|
||||
public function files(): hasMany
|
||||
public function files(): hasMany
|
||||
{
|
||||
return $this->hasMany(File::class, 'document_id');
|
||||
}
|
||||
|
||||
+2
-30
@@ -2,45 +2,17 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* Class File
|
||||
*
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
* @property Document document_id
|
||||
*
|
||||
* @property \App\Models\Document document_id
|
||||
* @property text file
|
||||
* @property int file_type_id
|
||||
* @property int $id
|
||||
* @property string $file_type
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|File newModelQuery()
|
||||
* @method static Builder|File newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|File onlyTrashed()
|
||||
* @method static Builder|File query()
|
||||
* @method static Builder|File whereCreatedAt($value)
|
||||
* @method static Builder|File whereDeletedAt($value)
|
||||
* @method static Builder|File whereDocumentId($value)
|
||||
* @method static Builder|File whereFile($value)
|
||||
* @method static Builder|File whereFileType($value)
|
||||
* @method static Builder|File whereId($value)
|
||||
* @method static Builder|File whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|File withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|File withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class File extends AbstractModel
|
||||
{
|
||||
|
||||
+13
-32
@@ -3,9 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -13,46 +10,30 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use App\Classes\General\Interfaces\Transactionable;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\Group
|
||||
*
|
||||
* @property-read Currency|null $currency
|
||||
* @property-read Collection|Document[] $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read CompanyModule|null $issuerCompany
|
||||
* @property-read Currency|null $original_currency
|
||||
* @property-read CompanyModule|null $receiverCompany
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @method static Builder|Group newModelQuery()
|
||||
* @method static Builder|Group newQuery()
|
||||
* @method static Builder|Group query()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Group extends Model implements Documentable, Transactionable
|
||||
{
|
||||
use HasRelationships;
|
||||
use HasTableAlias;
|
||||
|
||||
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||
use SoftDeletes;
|
||||
|
||||
// /**
|
||||
// * @return MorphMany
|
||||
// */
|
||||
// public function transactions(): MorphMany
|
||||
// {
|
||||
// return $this->belongsToMany(Transaction::class, GroupTransaction::class);
|
||||
// return $this->MorphMany(Transaction::class, 'owner');
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function transactions(): MorphMany
|
||||
{
|
||||
return $this->MorphMany(Transaction::class, 'owner');
|
||||
return $this->MorphMany(GroupTransaction::class, 'group');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function groupTransactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(GroupTransaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,70 +11,14 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Scopes\CustomerOrdersScope;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* App\Models\Order
|
||||
*
|
||||
* @method static whereBetween(string $string, array $array)
|
||||
* @property int $id
|
||||
* @property int $company_module_id
|
||||
* @property string $reference
|
||||
* @property string|null $reference_contract
|
||||
* @property int $type Order packages can be shipped in shared or dedicated container
|
||||
* @property int $status Status of this order, e.g. processing, shipping etc.
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|OrderRole[] $OrderRoles
|
||||
* @property-read int|null $order_roles_count
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Collection|Addon[] $addons
|
||||
* @property-read int|null $addons_count
|
||||
* @property-read Collection|Address[] $addresses
|
||||
* @property-read int|null $addresses_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read CompanyModule|null $companyModule
|
||||
* @property-read Collection|Step[] $orderSteps
|
||||
* @property-read int|null $order_steps_count
|
||||
* @property-read Collection|PackingList[] $packingLists
|
||||
* @property-read int|null $packing_lists_count
|
||||
* @property-read Collection|Package[] $parcels
|
||||
* @property-read int|null $parcels_count
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order newQuery()
|
||||
* @method static Builder|Order onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereCompanyModuleId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereReference($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereReferenceContract($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Order whereUpdatedAt($value)
|
||||
* @method static Builder|Order withTrashed()
|
||||
* @method static Builder|Order withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -7,71 +7,15 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||
use App\Scopes\CustomerOrdersScope;
|
||||
use App\Scopes\CustomerPackagesScope;
|
||||
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasOneDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
/**
|
||||
* App\Models\Package
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $packing_list_id
|
||||
* @property int $type
|
||||
* @property string|null $reference
|
||||
* @property string|null $description
|
||||
* @property string $width
|
||||
* @property string $height
|
||||
* @property string $length
|
||||
* @property string $weight
|
||||
* @property int $quantity
|
||||
* @property int $status
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Collection|Transport[] $deliveryTransports
|
||||
* @property-read int|null $delivery_transports_count
|
||||
* @property-read PackingList|null $packingList
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package newQuery()
|
||||
* @method static Builder|Package onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package shipped()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package shipping()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package shippingList()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package warehouseReceiveList()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereHeight($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereLength($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package wherePackingListId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereQuantity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereReference($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereWeight($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Package whereWidth($value)
|
||||
* @method static Builder|Package withTrashed()
|
||||
* @method static Builder|Package withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Package extends AbstractModel
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
@@ -10,78 +10,15 @@ use App\Classes\General\Interfaces\Transactionable;
|
||||
use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||
|
||||
/**
|
||||
* App\Models\PackingList
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property int|null $claimant_id
|
||||
* @property string|null $reference_contract
|
||||
* @property string $reference
|
||||
* @property int $type
|
||||
* @property int $status
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Collection|Addon[] $addons
|
||||
* @property-read int|null $addons_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Collection|Container[] $containers
|
||||
* @property-read int|null $containers_count
|
||||
* @property-read Model|Eloquent $owner
|
||||
* @property-read Collection|Package[] $packages
|
||||
* @property-read int|null $packages_count
|
||||
* @property-read Collection|PackingList[] $packingLists
|
||||
* @property-read int|null $packing_lists_count
|
||||
* @property-read Collection|PackingList[] $packing_list_owner
|
||||
* @property-read int|null $packing_list_owner_count
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Collection|Step[] $steps
|
||||
* @property-read int|null $steps_count
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read Collection|Transport[] $transports
|
||||
* @property-read int|null $transports_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList newQuery()
|
||||
* @method static Builder|PackingList onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList shipping()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereClaimantId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereOwnerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereOwnerType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereReference($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereReferenceContract($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PackingList whereUpdatedAt($value)
|
||||
* @method static Builder|PackingList withTrashed()
|
||||
* @method static Builder|PackingList withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class PackingList extends AbstractModel implements Transportable, Steppable, Packable, Transactionable
|
||||
{
|
||||
use HasTableAlias;
|
||||
@@ -94,7 +31,7 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
||||
protected $fillable = ['status'];
|
||||
|
||||
/**
|
||||
* @return MorphTo
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
|
||||
@@ -2,50 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* App\Models\Remark
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property int $commenter_id
|
||||
* @property string $content
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read User|null $commenter
|
||||
* @property-read Model|Eloquent $owner
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark newQuery()
|
||||
* @method static Builder|Remark onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereCommenterId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereContent($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereOwnerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereOwnerType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Remark whereUpdatedAt($value)
|
||||
* @method static Builder|Remark withTrashed()
|
||||
* @method static Builder|Remark withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Remark extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RouteLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'ip_address',
|
||||
'url',
|
||||
'request_method',
|
||||
'browser',
|
||||
'platform',
|
||||
'longitude',
|
||||
'latitude',
|
||||
'last_page',
|
||||
'countryname',
|
||||
'route_type'
|
||||
];
|
||||
}
|
||||
@@ -4,51 +4,10 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* App\Models\Schedule
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property \Illuminate\Support\Carbon|null $etd
|
||||
* @property \Illuminate\Support\Carbon|null $eta
|
||||
* @property int $status
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read Collection|\Spatie\Activitylog\Models\Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Model|\Eloquent $owner
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @property-read Transport|null $transport
|
||||
* @method static Builder|Schedule dispatched()
|
||||
* @method static Builder|Schedule dropped()
|
||||
* @method static Builder|Schedule newModelQuery()
|
||||
* @method static Builder|Schedule newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Schedule onlyTrashed()
|
||||
* @method static Builder|Schedule query()
|
||||
* @method static Builder|Schedule whereCreatedAt($value)
|
||||
* @method static Builder|Schedule whereDeletedAt($value)
|
||||
* @method static Builder|Schedule whereEta($value)
|
||||
* @method static Builder|Schedule whereEtd($value)
|
||||
* @method static Builder|Schedule whereId($value)
|
||||
* @method static Builder|Schedule whereOwnerId($value)
|
||||
* @method static Builder|Schedule whereOwnerType($value)
|
||||
* @method static Builder|Schedule whereStatus($value)
|
||||
* @method static Builder|Schedule whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Schedule withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Schedule withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Schedule extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
@@ -9,94 +9,14 @@ use App\Classes\General\Traits\LogData;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* App\Models\Transaction
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property string $type
|
||||
* @property int $issuer
|
||||
* @property int $receiver
|
||||
* @property int $recipient_bank_account_id
|
||||
* @property string|null $payment_method
|
||||
* @property string|null $payment_reference
|
||||
* @property string $bill_no
|
||||
* @property string $amount
|
||||
* @property string $original_amount
|
||||
* @property int $currency_id
|
||||
* @property int $original_currency_id
|
||||
* @property string $currency_rate
|
||||
* @property string $tax
|
||||
* @property string $service_charge
|
||||
* @property string|null $expires_on
|
||||
* @property int $status
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Currency $currency
|
||||
* @property-read Collection|Document[] $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read Collection|Order[] $order
|
||||
* @property-read int|null $order_count
|
||||
* @property-read Currency $original_currency
|
||||
* @property-read Model|Eloquent $owner
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @property-read Collection|TransactionDetail[] $transactionDetails
|
||||
* @property-read int|null $transaction_details_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @method static Builder|Transaction complete()
|
||||
* @method static Builder|Transaction inComplete()
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
* @method static Builder|Transaction newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction onlyTrashed()
|
||||
* @method static Builder|Transaction payments()
|
||||
* @method static Builder|Transaction query()
|
||||
* @method static Builder|Transaction transferred()
|
||||
* @method static Builder|Transaction whereAmount($value)
|
||||
* @method static Builder|Transaction whereBillNo($value)
|
||||
* @method static Builder|Transaction whereCreatedAt($value)
|
||||
* @method static Builder|Transaction whereCurrencyId($value)
|
||||
* @method static Builder|Transaction whereCurrencyRate($value)
|
||||
* @method static Builder|Transaction whereDeletedAt($value)
|
||||
* @method static Builder|Transaction whereExpiresOn($value)
|
||||
* @method static Builder|Transaction whereId($value)
|
||||
* @method static Builder|Transaction whereIssuer($value)
|
||||
* @method static Builder|Transaction whereOriginalAmount($value)
|
||||
* @method static Builder|Transaction whereOriginalCurrencyId($value)
|
||||
* @method static Builder|Transaction whereOwnerId($value)
|
||||
* @method static Builder|Transaction whereOwnerType($value)
|
||||
* @method static Builder|Transaction wherePaymentMethod($value)
|
||||
* @method static Builder|Transaction wherePaymentReference($value)
|
||||
* @method static Builder|Transaction whereReceiver($value)
|
||||
* @method static Builder|Transaction whereRecipientBankAccountId($value)
|
||||
* @method static Builder|Transaction whereServiceCharge($value)
|
||||
* @method static Builder|Transaction whereStatus($value)
|
||||
* @method static Builder|Transaction whereTax($value)
|
||||
* @method static Builder|Transaction whereType($value)
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
||||
{
|
||||
use SoftDeletes;
|
||||
@@ -157,6 +77,14 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
return $this->HasMany(TransactionDetail::class, 'transaction_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function groups(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Group::class, GroupTransaction::class, 'transaction_id');
|
||||
}
|
||||
|
||||
public function convert_original_amount()
|
||||
{
|
||||
if($this->booking()->first()->fix_currency_id !== 1) {
|
||||
|
||||
@@ -2,49 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
|
||||
/**
|
||||
* App\Models\TransactionDetail
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $transaction_id
|
||||
* @property string $reference
|
||||
* @property string $name
|
||||
* @property string $quantity
|
||||
* @property string $price
|
||||
* @property string $amount
|
||||
* @property string|null $deleted_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|Eloquent $causer
|
||||
* @property-read Model|Eloquent $subject
|
||||
* @property-read Model|Eloquent $target
|
||||
* @property-read Transaction $transaction
|
||||
* @method static Builder|TransactionDetail newModelQuery()
|
||||
* @method static Builder|TransactionDetail newQuery()
|
||||
* @method static Builder|TransactionDetail query()
|
||||
* @method static Builder|TransactionDetail whereAmount($value)
|
||||
* @method static Builder|TransactionDetail whereCreatedAt($value)
|
||||
* @method static Builder|TransactionDetail whereDeletedAt($value)
|
||||
* @method static Builder|TransactionDetail whereId($value)
|
||||
* @method static Builder|TransactionDetail whereName($value)
|
||||
* @method static Builder|TransactionDetail wherePrice($value)
|
||||
* @method static Builder|TransactionDetail whereQuantity($value)
|
||||
* @method static Builder|TransactionDetail whereReference($value)
|
||||
* @method static Builder|TransactionDetail whereTransactionId($value)
|
||||
* @method static Builder|TransactionDetail whereUpdatedAt($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionDetail extends AbstractModel
|
||||
{
|
||||
protected $table = 'transaction_details';
|
||||
|
||||
@@ -4,59 +4,10 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
/**
|
||||
* App\Models\Transport
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $owner_type
|
||||
* @property int $owner_id
|
||||
* @property int $type
|
||||
* @property string|null $courier
|
||||
* @property string|null $tracking_number
|
||||
* @property \Illuminate\Support\Carbon|null $dispatch_date
|
||||
* @property \Illuminate\Support\Carbon|null $drop_date
|
||||
* @property int $status
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Model|\Eloquent $owner
|
||||
* @property-read Collection|Schedule[] $schedules
|
||||
* @property-read int|null $schedules_count
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static Builder|Transport dispatched()
|
||||
* @method static Builder|Transport dropped()
|
||||
* @method static Builder|Transport newModelQuery()
|
||||
* @method static Builder|Transport newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport onlyTrashed()
|
||||
* @method static Builder|Transport query()
|
||||
* @method static Builder|Transport whereCourier($value)
|
||||
* @method static Builder|Transport whereCreatedAt($value)
|
||||
* @method static Builder|Transport whereDeletedAt($value)
|
||||
* @method static Builder|Transport whereDispatchDate($value)
|
||||
* @method static Builder|Transport whereDropDate($value)
|
||||
* @method static Builder|Transport whereId($value)
|
||||
* @method static Builder|Transport whereOwnerId($value)
|
||||
* @method static Builder|Transport whereOwnerType($value)
|
||||
* @method static Builder|Transport whereStatus($value)
|
||||
* @method static Builder|Transport whereTrackingNumber($value)
|
||||
* @method static Builder|Transport whereType($value)
|
||||
* @method static Builder|Transport whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transport withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Transport extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
@@ -68,7 +19,7 @@ class Transport extends AbstractModel
|
||||
protected $dates = ['dispatch_date', 'drop_date'];
|
||||
|
||||
/**
|
||||
* @return MorphTo
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
*/
|
||||
public function owner(): morphTo
|
||||
{
|
||||
|
||||
+1
-67
@@ -2,19 +2,10 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
use Illuminate\Notifications\DatabaseNotification;
|
||||
use Illuminate\Notifications\DatabaseNotificationCollection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -28,70 +19,13 @@ use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
/**
|
||||
* App\Models\User
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property int $type
|
||||
* @property int $status
|
||||
* @property string|null $remember_token
|
||||
* @property string|null $active_at
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property-read Collection|Activity[] $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read Model|\Eloquent $causer
|
||||
* @property-read Collection|CompanyModule[] $companyModule
|
||||
* @property-read int|null $company_module_count
|
||||
* @property-read Collection|Contact[] $contacts
|
||||
* @property-read int|null $contacts_count
|
||||
* @property-read Collection|UserEmailVerification[] $emailVerification
|
||||
* @property-read int|null $email_verification_count
|
||||
* @property-read DatabaseNotificationCollection|DatabaseNotification[] $notifications
|
||||
* @property-read int|null $notifications_count
|
||||
* @property-read Collection|PasswordReset[] $passwordReset
|
||||
* @property-read int|null $password_reset_count
|
||||
* @property-read Collection|Permission[] $permissions
|
||||
* @property-read int|null $permissions_count
|
||||
* @property-read Collection|Remark[] $remarks
|
||||
* @property-read int|null $remarks_count
|
||||
* @property-read Collection|Role[] $roles
|
||||
* @property-read int|null $roles_count
|
||||
* @property-read Model|\Eloquent $subject
|
||||
* @property-read Model|\Eloquent $target
|
||||
* @method static UserFactory factory(...$parameters)
|
||||
* @method static Builder|User newModelQuery()
|
||||
* @method static Builder|User newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|User onlyTrashed()
|
||||
* @method static Builder|User permission($permissions)
|
||||
* @method static Builder|User query()
|
||||
* @method static Builder|User role($roles, $guard = null)
|
||||
* @method static Builder|User whereActiveAt($value)
|
||||
* @method static Builder|User whereCreatedAt($value)
|
||||
* @method static Builder|User whereDeletedAt($value)
|
||||
* @method static Builder|User whereEmail($value)
|
||||
* @method static Builder|User whereId($value)
|
||||
* @method static Builder|User whereName($value)
|
||||
* @method static Builder|User wherePassword($value)
|
||||
* @method static Builder|User whereRememberToken($value)
|
||||
* @method static Builder|User whereStatus($value)
|
||||
* @method static Builder|User whereType($value)
|
||||
* @method static Builder|User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|User withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|User withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends AbstractModel implements
|
||||
JWTSubject,
|
||||
AuthenticatableContract,
|
||||
AuthorizableContract,
|
||||
CanResetPasswordContract
|
||||
{
|
||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes, HasFactory;
|
||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\Address;
|
||||
use App\Models\Company;
|
||||
use App\Models\Order;
|
||||
use App\Models\SegmentConstant;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class AddressTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'contact',
|
||||
'remark'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'company_module',
|
||||
'Owner_address',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param Address $address
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Address $address): array
|
||||
{
|
||||
return [
|
||||
'id' => $address->id,
|
||||
'reference' => $address->reference,
|
||||
'street_one' => $address->street_one,
|
||||
'street_two' => $address->street_two,
|
||||
'district' => $address->district,
|
||||
'state' => $address->state,
|
||||
'postcode' => $address->postcode,
|
||||
'post_code' => $address->postcode,
|
||||
'post_code_area' => $this->getPostalCodeArea($address),
|
||||
'country' => $address->country,
|
||||
'default' => $address->default,
|
||||
'status' => $address->status,
|
||||
'type' => $address->type,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Postal code Area
|
||||
* @param Address $address
|
||||
* @return string|null
|
||||
*/
|
||||
private function getPostalCodeArea(Address $address): ?string
|
||||
{
|
||||
$centerPostcodeConstantObject = SegmentConstant::where('reference', SegmentConstants::CENTER_POSTCODE)->get();
|
||||
$centerPostcodeConstant = $centerPostcodeConstantObject->isEmpty() ? [] : (array)$centerPostcodeConstantObject->first()->value;
|
||||
return in_array($address->postcode, $centerPostcodeConstant) ? 'CENTER_POSTCODE' : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Contact
|
||||
*
|
||||
* @param Address $address
|
||||
* @return Item
|
||||
*/
|
||||
public function includeContact(Address $address): Item
|
||||
{
|
||||
$contact = $address->contacts();
|
||||
|
||||
return $this->item($contact->first(), new ContactTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include in Remark
|
||||
* @param Address $address
|
||||
* @return Item
|
||||
*/
|
||||
public function includeRemark(Address $address): Item
|
||||
{
|
||||
$remarks = $address->remarks();
|
||||
return $this->item($remarks->first(), new RemarkTransformer());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ?Owner Address info
|
||||
* @param Address $address
|
||||
* @return array
|
||||
*/
|
||||
public function includeOwner_address(Address $address): array
|
||||
{
|
||||
|
||||
return [
|
||||
'owner' => $address->when($address->owner instanceof Order, [
|
||||
'reference' => $address->owner->reference,
|
||||
'company_module' => $this->item($address->owner->companyModule, new RemarkTransformer()),
|
||||
'address' => $this->item($address->owner->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first(), new AddressTransformer()),
|
||||
])
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Announcement;
|
||||
use Carbon\Carbon;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class AnnouncementTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param Announcement $announcement
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Announcement $announcement): array
|
||||
{
|
||||
return [
|
||||
'id' => $announcement->id,
|
||||
'title' => $announcement->title,
|
||||
'description' => $announcement->description,
|
||||
'segments' => $announcement->segments,
|
||||
'starting_on' => Carbon::parse($announcement->starting_on)->format('d-m-Y'),
|
||||
'ending_on' => Carbon::parse($announcement->ending_on)->format('d-m-Y'),
|
||||
'created_at' => Carbon::parse($announcement->created_at)->format('d-m-Y'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\BankAccount;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class BankAccountTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'company_business_type'
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param BankAccount $account
|
||||
* @return array
|
||||
*/
|
||||
public function transform(BankAccount $account): array
|
||||
{
|
||||
return [
|
||||
'id' => $account->id,
|
||||
'company_business_type' => $account->company->business_type,
|
||||
'type' => $account->type,
|
||||
'reference' => $account->reference,
|
||||
'bank_name' => $account->bank_name,
|
||||
'bank_branch' => $account->bank_branch,
|
||||
'holder_name' => $account->holder_name,
|
||||
'account_no' => $account->account_no,
|
||||
'country_id' => $account->country_id,
|
||||
'default' => $account->default,
|
||||
'status' => $account->status,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Models\CompanyModule;
|
||||
use App\Models\SegmentConstant;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class CompanyModuleTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'address',
|
||||
'billingAddress',
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'company',
|
||||
'remarks',
|
||||
'contact'
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param CompanyModule $module
|
||||
* @return array
|
||||
*/
|
||||
public function transform(CompanyModule $module): array
|
||||
{
|
||||
return [
|
||||
'id' => $module->id,
|
||||
'type' => $module->type,
|
||||
'name' => $module->name,
|
||||
'reference' => $module->reference,
|
||||
'connections' => $module->connections,
|
||||
'marking' => $this->getMarkings($module),
|
||||
'warehouseCharges' => $this->calculateWarehouseCharges($module),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Default Address
|
||||
* @param CompanyModule $module
|
||||
* @return Item
|
||||
*/
|
||||
public function includeAddress(CompanyModule $module): \League\Fractal\Resource\Item
|
||||
{
|
||||
$defaultAddress = $module->addresses()->defaultAddress()->first();
|
||||
$defaultAddress = $defaultAddress ? $defaultAddress : $this->addresses()->first();
|
||||
|
||||
return $this->item($defaultAddress, new AddressTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Billing Address
|
||||
* @param CompanyModule $module
|
||||
* @return Item
|
||||
*/
|
||||
|
||||
public function includeBillingAddress(CompanyModule $module): Item
|
||||
{
|
||||
$billingAddress = $module->addresses()->where('type', AddressType::BILLING)->where('status', ApprovalStatus::APPROVED)->first();
|
||||
return $this->item($billingAddress, new AddressTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* include the company
|
||||
* @param CompanyModule $module
|
||||
* @return Item
|
||||
*/
|
||||
public function includeCompany(CompanyModule $module): Item
|
||||
{
|
||||
$company = $module->company()->first();
|
||||
return $this->item($company, new CompanyTransformer());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Remarks
|
||||
* @param CompanyModule $module
|
||||
* @return Collection
|
||||
*/
|
||||
public function includeRemarks(CompanyModule $module): Collection
|
||||
{
|
||||
$remarks = $module->remarks();
|
||||
return $this->collection($remarks, new RemarkTransformer);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Markings
|
||||
* @param CompanyModule $module
|
||||
* @return string
|
||||
*/
|
||||
public function getMarkings(CompanyModule $module): string
|
||||
{
|
||||
$connection = $module->inviters()->withPivot('invitee_reference')->first();
|
||||
return $connection ? $connection->pivot->invitee_reference : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate warehouse charges
|
||||
* @param CompanyModule $module
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function calculateWarehouseCharges(CompanyModule $module)
|
||||
{
|
||||
$segmentConstantObject = SegmentConstant::where('reference', SegmentConstants::WAREHOUSE_RATE)->get();
|
||||
$segmentConstant = $segmentConstantObject->isEmpty() ? [] : (array)$segmentConstantObject->first()->value;
|
||||
|
||||
return array_key_exists($module->id, $segmentConstant) ? $segmentConstant[$module->id] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* include the contact
|
||||
* @param CompanyModule $module
|
||||
* @return Item
|
||||
*/
|
||||
public function includeContact(CompanyModule $module): Item
|
||||
{
|
||||
$contact = $module->contacts()->first();
|
||||
return $this->item($contact, new ContactTransformer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class CompanyTransformer extends TransformerAbstract
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* List of all default includes
|
||||
*/
|
||||
protected array $defaultIncludes = [
|
||||
'contact',
|
||||
];
|
||||
|
||||
/**
|
||||
* List of all possible includes
|
||||
* @var array|string[]
|
||||
*/
|
||||
protected array $availableIncludes = [
|
||||
|
||||
'segments',
|
||||
'employee',
|
||||
'company_module',
|
||||
'last_order',
|
||||
'order_count',
|
||||
'identification',
|
||||
];
|
||||
|
||||
public function transform(Company $company): array
|
||||
{
|
||||
return [
|
||||
'id' => $company->id,
|
||||
'hash_id' => Crypt::encryptString($company->id),
|
||||
'name' => $company->name,
|
||||
'debtor' => $company->debtor,
|
||||
'reference' => $company->reference,
|
||||
'type' => $company->type,
|
||||
'business_type' => (int)$company->business_type,
|
||||
'status' => $company->status,
|
||||
'created_at' => $company->created_at->format('d-m-Y')
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Include Contact
|
||||
*
|
||||
* @param Company $company
|
||||
* @return Item
|
||||
*/
|
||||
public function includeContact(Company $company): Item
|
||||
{
|
||||
$contact = $company->contacts();
|
||||
|
||||
return $this->item($contact->first(), new ContactTransformer());
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Contact;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class ContactTransformer extends TransformerAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Additional includes to the ContactResource
|
||||
*/
|
||||
protected array $defaultIncludes = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Transform contact
|
||||
* @param Contact $contact
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Contact $contact): array
|
||||
{
|
||||
return [
|
||||
'id' => $contact->id,
|
||||
'reference' => $contact->reference,
|
||||
'phone' => $contact->phone,
|
||||
'email' => $contact->email,
|
||||
'wechat_id' => $contact->wechat_id,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ContainerTypes;
|
||||
use App\Models\Container;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class ContainerTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'transport',
|
||||
'remarks'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'packing_lists'
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param Container $container
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Container $container): array
|
||||
{
|
||||
return [
|
||||
'id' => $container->id,
|
||||
'container_reference' => $container->reference,
|
||||
'container_specification' => ContainerTypes::CONTAINER_SPECIFICATION[$container->container_type],
|
||||
'container_number' => $container->container_number,
|
||||
'seal_reference' => $container->seal_reference,
|
||||
'loading_date' => $container->loading_date ? $container->loading_date->format('d-m-Y') : $container->loading_date,
|
||||
'packages_count' => $container->packages()->where('packages.type', '!=', 2)->sum('quantity'),
|
||||
'total_cbm' => $container->packages()->sum(DB::raw('(width/100) * (height/100) * (length/100) * quantity')),
|
||||
'status' => $container->status,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Transport
|
||||
* @param Container $container
|
||||
* @return Item
|
||||
*/
|
||||
public function includeTransport(Container $container): Item
|
||||
{
|
||||
$container = $container->transport()->first();
|
||||
return $this->item($container, new TransportTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Remarks
|
||||
* @param Container $container
|
||||
* @return Collection
|
||||
*/
|
||||
public function includeRemarks(Container $container): Collection
|
||||
{
|
||||
$remarks = $container->remarks()->get();
|
||||
return $this->collection($remarks, new RemarkTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* include Packages Lists
|
||||
* @param Container $container
|
||||
* @return Collection
|
||||
*/
|
||||
public function includePackagesList(Container $container): Collection
|
||||
{
|
||||
$packages = $container->packingLists()->get()->sortBy(function ($packingList) {
|
||||
return $packingList->owner->company_module_id;
|
||||
});
|
||||
return $this->collection($packages, new PackageListTransformer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Currency;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class CurrencyTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param Currency $currency
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Currency $currency): array
|
||||
{
|
||||
return [
|
||||
'id' => $currency->id,
|
||||
'name' => $currency->name,
|
||||
'short_code' => $currency->short_code,
|
||||
'phone_code' => $currency->phone_code,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\PackingList;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class DeliverPackingListTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'transport',
|
||||
'packing_list',
|
||||
'company'
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param PackingList $list
|
||||
* @return array
|
||||
*/
|
||||
public function transform(PackingList $list): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->$list,
|
||||
'claimant_id' => $list->claimant_id,
|
||||
'reference' => $list->reference,
|
||||
'status' => $list->status,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* include transport
|
||||
* @param PackingList $list
|
||||
* @return Item
|
||||
*/
|
||||
public function includeTransport(PackingList $list): Item
|
||||
{
|
||||
return $this->item($list->transports()->first(), new TransportTransformer);
|
||||
}
|
||||
|
||||
/**
|
||||
* add packing list
|
||||
* @param PackingList $list
|
||||
* @return Collection
|
||||
*/
|
||||
public function includePackingList(PackingList $list): Collection
|
||||
{
|
||||
return $this->collection($list->packing_list_owner(), new PackageListTransformer);
|
||||
}
|
||||
|
||||
/**
|
||||
* add company
|
||||
* @param PackingList $list
|
||||
* @return Item
|
||||
*/
|
||||
public function includeCompany(PackingList $list): Item
|
||||
{
|
||||
return $this->item($list->owner(), new CompanyModuleTransformer);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\AddressType;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Order;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class DeliveryOrderTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'company_module',
|
||||
'sender_address',
|
||||
'delivery_address',
|
||||
'packingList',
|
||||
'remarks'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @param Order $order
|
||||
* @return array
|
||||
*/
|
||||
public function transform(Order $order): array
|
||||
{
|
||||
return [
|
||||
'id' => $order->id,
|
||||
'reference' => $order->reference,
|
||||
'type' => $order->type,
|
||||
'status' => $order->status,
|
||||
'created_at' => $order->created_at->format('d-m-Y')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Include CompanyModule
|
||||
* @param Order $order
|
||||
* @return Item
|
||||
*/
|
||||
public function includeCompanyModule(Order $order): Item
|
||||
{
|
||||
return $this->item($order->companyModule, new CompanyModuleTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include SenderAddress
|
||||
* @param Order $order
|
||||
* @return Item
|
||||
*/
|
||||
public function includeSenderAddress(Order $order): Item
|
||||
{
|
||||
return $this->item($order->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::PICK_UP)->first(), new AddressTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include DeliveryAddress
|
||||
* @param Order $order
|
||||
* @return Item
|
||||
*/
|
||||
|
||||
public function includeDeliveryAddress(Order $order): Item
|
||||
{
|
||||
return $this->item($order->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::DELIVERY)->first(), new AddressTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include PackingList
|
||||
* @param Order $order
|
||||
* @return Item
|
||||
*/
|
||||
public function includePackingList(Order $order): Item
|
||||
{
|
||||
return $this->item($order->packingLists()->first(), new DeliveryPackingListTransformer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Remarks
|
||||
* @param Order $order
|
||||
* @return Item
|
||||
*/
|
||||
public function includeRemarks(Order $order): Item
|
||||
{
|
||||
return $this->item($order->remarks, new RemarkTransformer());
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\PackingList;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class DeliveryPackingListTransformer extends TransformerAbstract
|
||||
{
|
||||
/**
|
||||
* List of resources to automatically include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
'transport'
|
||||
];
|
||||
|
||||
/**
|
||||
* List of resources possible to include
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A Fractal transformer.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function transform(PackingList $list): array
|
||||
{
|
||||
$package = $list->packages()->first();
|
||||
|
||||
return [
|
||||
'id' => $list->id,
|
||||
'claimant_id' => $list->claimant_id,
|
||||
'reference' => $list->reference,
|
||||
'status' => $list->status,
|
||||
'type' => $package->type,
|
||||
'description' => $package->description,
|
||||
'weight' => (float)$package->weight,
|
||||
'quantity' => (float)$package->quantity,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Include Transport
|
||||
*
|
||||
* @param PackingList $list
|
||||
* @return Item
|
||||
*/
|
||||
public function includeTransport(PackingList $list): Item
|
||||
{
|
||||
return $this->item($list->transports()->first(), new TransportTransformer());
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class DocumentTransformer extends TransformerAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Default Includes for Document Module
|
||||
* @var array
|
||||
*/
|
||||
protected array $defaultIncludes = [
|
||||
'files'
|
||||
];
|
||||
/**
|
||||
* Available includes
|
||||
* @var array
|
||||
*/
|
||||
protected array $availableIncludes = [
|
||||
'owner'
|
||||
];
|
||||
|
||||
public function transform(Document $document): array
|
||||
{
|
||||
return [
|
||||
'id' => $document->id,
|
||||
'reference' => $document->reference,
|
||||
'status' => $document->status,
|
||||
'document_type' => $document->document_type,
|
||||
'created_at' => Carbon::parse($document->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
|
||||
public function includeFiles(Document $document): Collection
|
||||
{
|
||||
$files = $document->files;
|
||||
return $this->collection($files, new FileTransformer());
|
||||
}
|
||||
|
||||
public function includeOwner(Document $document): Item
|
||||
{
|
||||
$owner = $document->owner;
|
||||
return $this->item($owner, new CompanyTransformer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\File;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
|
||||
class FileTransformer extends TransformerAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* AA Array of possible includes for file model
|
||||
* @var array
|
||||
*/
|
||||
protected array $availableIncludes = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Transform File
|
||||
* @param File $file
|
||||
* @return array
|
||||
*/
|
||||
public function transform(File $file): array
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => $file->id,
|
||||
'file' => $file->file,
|
||||
'type' => (int)$file->file_type,
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user