mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25cc1ffc42 | |||
| 358dcfa81a | |||
| 0570fef268 | |||
| 1d3042728c | |||
| bdc71c3ab6 | |||
| 902c72b225 | |||
| fafa3be998 | |||
| 96ff2f5e15 | |||
| bb1daa48a4 | |||
| 758624b29c | |||
| ffb5edc6e9 | |||
| 6902dc36c0 | |||
| c853b6dfea | |||
| df1cb83aa2 | |||
| d09a8a8b8d | |||
| 8347b2c1db | |||
| 37570193e7 | |||
| c0fdb44996 | |||
| a7429554f6 | |||
| dcfb73c952 | |||
| 41db8f57f5 | |||
| 18579d5c1d | |||
| 1060401128 | |||
| 3497de9727 | |||
| 5b00b7b45f | |||
| 965dfb3098 | |||
| e7c0e17ee4 | |||
| 569273c058 | |||
| 80f229c6ec | |||
| 56b6b59967 | |||
| d6fad96d4d | |||
| 351447b1fc | |||
| 842614700a | |||
| a0ca37ec16 | |||
| 08b2ba1c63 | |||
| c7f8831555 | |||
| df31b801f3 | |||
| 946c9b6e3d | |||
| bafc23bf6f | |||
| 2d13f69be6 | |||
| cb184c8f50 |
@@ -27,3 +27,6 @@ package-lock.json
|
||||
public/*
|
||||
/public/*
|
||||
storage/framework/laravel-excel/*
|
||||
.vapor/
|
||||
.env.production
|
||||
.env.staging
|
||||
|
||||
+39
-111
@@ -1,120 +1,48 @@
|
||||
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
|
||||
|
||||
- deploy
|
||||
|
||||
#jobs
|
||||
#deploy
|
||||
deploy:
|
||||
stage: deploy
|
||||
before_script:
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq
|
||||
- apt-get install -y libonig-dev
|
||||
- apt-get install -y libxml2-dev
|
||||
- apt-get install -y libzip-dev
|
||||
- apt-get install -y libgd-dev
|
||||
- apt-get install -y libgd-dev
|
||||
|
||||
#buld the backend
|
||||
composer_php:
|
||||
stage: service_build
|
||||
# Install PDO MySQL extension
|
||||
- docker-php-ext-install pdo_mysql
|
||||
|
||||
# Install php dependencies
|
||||
- docker-php-ext-install mbstring xml zip gd
|
||||
|
||||
# Install composer package manager
|
||||
- curl --location --output /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar
|
||||
- chmod +x /usr/local/bin/composer
|
||||
|
||||
# Install node js
|
||||
- apt-get update && apt-get install -y nodejs npm
|
||||
|
||||
# Install docker
|
||||
- apt-get update
|
||||
- apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release software-properties-common
|
||||
- curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
|
||||
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
|
||||
- apt-get update
|
||||
- apt-get install -y docker-ce docker-ce-cli containerd.io
|
||||
- service docker start
|
||||
|
||||
# Install gulp Js
|
||||
- npm install -g gulp-cli
|
||||
script:
|
||||
- composer install
|
||||
- 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 =~ /.*/'
|
||||
|
||||
|
||||
- vendor/bin/vapor deploy production --message="$CI_COMMIT_MESSAGE"
|
||||
only:
|
||||
- test
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class DoesNotHaveGroups implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->whereDoesntHave('groups');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class IdNext implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('id', '>', $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class NextMainQuestion implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('next_main_question', $value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class QuestionId implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('question_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class QuestionNumber implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('question_number', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class QuestionnaireSetId implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('questionnaire_set_id', $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\General\Eloquent\Filters;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class UserId implements Filter
|
||||
{
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param $value
|
||||
* @return Builder|mixed
|
||||
*/
|
||||
public static function apply(Builder $builder, $value)
|
||||
{
|
||||
return $builder->where('user_id', $value);
|
||||
}
|
||||
}
|
||||
@@ -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,14 +60,14 @@ 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')]);
|
||||
|
||||
|
||||
$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) {
|
||||
@@ -85,14 +80,6 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
||||
$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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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,12 +111,23 @@ 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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Processors;
|
||||
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Documents\Services\CreatesDocument;
|
||||
use App\Classes\Modules\Documents\Services\CreatesFiles;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
|
||||
class UploadDocumentForHelpMenuProcessor
|
||||
{
|
||||
|
||||
/** @var CreatesDocument */
|
||||
private $createsDocument;
|
||||
|
||||
/** @var CreatesFiles */
|
||||
private $createsFiles;
|
||||
|
||||
/**
|
||||
* UploadDocumentForHelpMenuProcessor constructor.
|
||||
* @param CreatesDocument $createsDocument
|
||||
* @param CreatesFiles $createsFiles
|
||||
*/
|
||||
public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFiles)
|
||||
{
|
||||
$this->createsDocument = $createsDocument;
|
||||
$this->createsFiles = $createsFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param QAUserAnswerSelected qaUserAnswerSelected
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Request $request, QAUserAnswerSelected $qaUserAnswerSelected) {
|
||||
$object = new DocumentObject("HELP_MENU", $request->input('files'),
|
||||
'123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded
|
||||
|
||||
/** @var Document $document */
|
||||
$document = $this->createsDocument->execute($qaUserAnswerSelected, $object);
|
||||
|
||||
$result = $this->createsFiles->execute($document, $object);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestionList;
|
||||
use App\Classes\Modules\HelpMenu\Processors\FetchFirstHelpMenuQuestionProcessor;
|
||||
use App\Http\Resources\HelpMenuQuestionResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class FetchHelpMenuQuestionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Help Menu First Question',
|
||||
'message' => 'You have successfully retrieved a Help Menu First Question'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchHelpMenuQuestionList */
|
||||
private $canFetchHelpMenuQuestionList;
|
||||
|
||||
/** @var FetchFirstHelpMenuQuestionProcessor */
|
||||
private $fetchFirstHelpMenuQuestionProcessor;
|
||||
|
||||
/**
|
||||
* FetchHelpMenuQuestionLogic constructor.
|
||||
* @param CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList
|
||||
* @param FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor
|
||||
*/
|
||||
public function __construct(CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList, FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor)
|
||||
{
|
||||
$this->canFetchHelpMenuQuestionList = $canFetchHelpMenuQuestionList;
|
||||
$this->fetchFirstHelpMenuQuestionProcessor = $fetchFirstHelpMenuQuestionProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$this->canFetchHelpMenuQuestionList->passes();
|
||||
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
$query = $this->fetchFirstHelpMenuQuestionProcessor->execute($request);
|
||||
|
||||
return $this->resourceResponse(new HelpMenuQuestionResource($query, $userId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMSupportTicket;
|
||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
||||
use App\Classes\Modules\HelpMenu\Standards\Rules\CanFetchHelpMenuQuestionList;
|
||||
use App\Classes\Modules\HelpMenu\Processors\SaveHelpMenuAnswerProcessor;
|
||||
use App\Classes\Modules\HelpMenu\Processors\DeleteHelpMenuAnswerProcessor;
|
||||
use App\Classes\Modules\HelpMenu\Processors\FetchNextHelpMenuQuestionProcessor;
|
||||
use App\Classes\Modules\HelpMenu\Processors\FetchFirstHelpMenuQuestionProcessor;
|
||||
use App\Http\Resources\HelpMenuQuestionResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Classes\ValueObjects\Constants\QAType;
|
||||
|
||||
class UpdateHelpMenuNextQuestionLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Help Menu Next Question',
|
||||
'message' => 'You have successfully retrieved a Help Menu Next Question'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchHelpMenuQuestionList */
|
||||
private $canFetchHelpMenuQuestionList;
|
||||
|
||||
/** @var SaveHelpMenuAnswerProcessor */
|
||||
private $saveHelpMenuAnswerProcessor;
|
||||
|
||||
/** @var DeleteHelpMenuAnswerProcessor */
|
||||
private $deleteHelpMenuAnswerProcessor;
|
||||
|
||||
/** @var FetchNextHelpMenuQuestionProcessor */
|
||||
private $fetchNextHelpMenuQuestionProcessor;
|
||||
|
||||
/** @var FetchFirstHelpMenuQuestionProcessor */
|
||||
private $fetchFirstHelpMenuQuestionProcessor;
|
||||
|
||||
/** @var CreatesPerfexCRMSupportTicket */
|
||||
private $createsPerfexCRMSupportTicket;
|
||||
|
||||
/** @var FetchesPerfexCRMCustomer */
|
||||
private $fetchesPerfexCRMCustomer;
|
||||
|
||||
/**
|
||||
* UpdateHelpMenuNextQuestionLogic constructor.
|
||||
* @param CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList
|
||||
* @param SaveHelpMenuAnswerProcessor $saveHelpMenuAnswerProcessor
|
||||
* @param FetchNextHelpMenuQuestionProcessor $fetchNextHelpMenuQuestionProcessor
|
||||
* @param FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor
|
||||
* @param DeleteHelpMenuAnswerProcessor $deleteHelpMenuAnswerProcessor
|
||||
*/
|
||||
public function __construct(CanFetchHelpMenuQuestionList $canFetchHelpMenuQuestionList, SaveHelpMenuAnswerProcessor $saveHelpMenuAnswerProcessor, FetchNextHelpMenuQuestionProcessor $fetchNextHelpMenuQuestionProcessor, FetchFirstHelpMenuQuestionProcessor $fetchFirstHelpMenuQuestionProcessor, CreatesPerfexCRMSupportTicket $createsPerfexCRMSupportTicket, FetchesPerfexCRMCustomer $fetchesPerfexCRMCustomer, DeleteHelpMenuAnswerProcessor $deleteHelpMenuAnswerProcessor)
|
||||
{
|
||||
$this->canFetchHelpMenuQuestionList = $canFetchHelpMenuQuestionList;
|
||||
$this->saveHelpMenuAnswerProcessor = $saveHelpMenuAnswerProcessor;
|
||||
$this->fetchNextHelpMenuQuestionProcessor = $fetchNextHelpMenuQuestionProcessor;
|
||||
$this->fetchFirstHelpMenuQuestionProcessor = $fetchFirstHelpMenuQuestionProcessor;
|
||||
$this->createsPerfexCRMSupportTicket = $createsPerfexCRMSupportTicket;
|
||||
$this->fetchesPerfexCRMCustomer = $fetchesPerfexCRMCustomer;
|
||||
$this->deleteHelpMenuAnswerProcessor = $deleteHelpMenuAnswerProcessor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$questionId = 0;
|
||||
$userId = Auth::user()->id;
|
||||
$currentQuestion = $request->question;
|
||||
$questionId = $currentQuestion['id'];
|
||||
$questionType = $currentQuestion['question_type'];
|
||||
|
||||
$this->canFetchHelpMenuQuestionList->passes();
|
||||
|
||||
//Delete answer
|
||||
$this->deleteHelpMenuAnswerProcessor->execute($userId, $questionId, $request);
|
||||
|
||||
//Save answer given by user
|
||||
if (!$request->has('isPrevious')) {
|
||||
$this->saveHelpMenuAnswerProcessor->execute($userId, $questionId, $request);
|
||||
}
|
||||
|
||||
//Create ticket at crm
|
||||
if (!$request->has('isPrevious')) {
|
||||
if($questionType == QAType::TICKET_CRM){
|
||||
$email = Auth::user()->email;
|
||||
$customer = $this->fetchesPerfexCRMCustomer->execute($email);
|
||||
$subject = "test subject 3";
|
||||
$department = 1;
|
||||
$contactid = 0;
|
||||
$userid = 0;
|
||||
if($customer){
|
||||
$contactid = $customer->id;
|
||||
$userid = $customer->userid;
|
||||
}
|
||||
$this->createsPerfexCRMSupportTicket->execute($subject, $department, $contactid, $userid);
|
||||
}
|
||||
}
|
||||
|
||||
//Get returned question (previous or next)
|
||||
$returnQuestion = $this->fetchNextHelpMenuQuestionProcessor->execute($request);
|
||||
//When a questionnaire ended, return back the first question
|
||||
if(is_null($returnQuestion)){
|
||||
$returnQuestion = $this->fetchFirstHelpMenuQuestionProcessor->execute($request);
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new HelpMenuQuestionResource($returnQuestion, $userId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Processors;
|
||||
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuUserAnswerSelected;
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuUserAnswerSelectedList;
|
||||
|
||||
class DeleteHelpMenuAnswerProcessor
|
||||
{
|
||||
/** @var FetchesHelpMenuUserAnswerSelected */
|
||||
private $fetchesHelpMenuUserAnswerSelected;
|
||||
|
||||
/** @var FetchesHelpMenuUserAnswerSelectedList */
|
||||
private $fetchesHelpMenuUserAnswerSelectedList;
|
||||
|
||||
/**
|
||||
* DeleteHelpMenuAnswerProcessor constructor.
|
||||
* @param FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected
|
||||
* @param FetchesHelpMenuUserAnswerSelectedList $fetchesHelpMenuUserAnswerSelectedList
|
||||
*/
|
||||
public function __construct(FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected, FetchesHelpMenuUserAnswerSelectedList $fetchesHelpMenuUserAnswerSelectedList)
|
||||
{
|
||||
$this->fetchesHelpMenuUserAnswerSelected = $fetchesHelpMenuUserAnswerSelected;
|
||||
$this->fetchesHelpMenuUserAnswerSelectedList = $fetchesHelpMenuUserAnswerSelectedList;
|
||||
}
|
||||
|
||||
public function execute($userId, $questionId, $request){
|
||||
if ($request->has('isPrevious')) {
|
||||
//Get current and previous question's answer
|
||||
try{
|
||||
$selectedAnswer = $this->fetchesHelpMenuUserAnswerSelectedList->execute(['user_id' => $userId, 'question_id' => $questionId, 'order_by' => (object)['column' => 'id','DESC' => true]])[0];
|
||||
} catch (\Exception $exception){
|
||||
$selectedAnswer = null;
|
||||
}
|
||||
|
||||
if($selectedAnswer)
|
||||
{
|
||||
$this->fetchesHelpMenuUserAnswerSelected->execute(['id' => $selectedAnswer['id']])->delete();
|
||||
}
|
||||
}
|
||||
else{
|
||||
//Delete all answer's belongs to the user
|
||||
$currentQuestion = $request->question;
|
||||
$isStart = $currentQuestion['is_start'];
|
||||
if($isStart){
|
||||
QAUserAnswerSelected::where('user_id', $userId)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Processors;
|
||||
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuQuestion;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class FetchFirstHelpMenuQuestionProcessor
|
||||
{
|
||||
/** @var FetchesHelpMenuQuestion */
|
||||
private $fetchesHelpMenuQuestion;
|
||||
|
||||
/**
|
||||
* FetchFirstHelpMenuQuestionProcessor constructor.
|
||||
* @param FetchesHelpMenuQuestion $fetchesHelpMenuQuestion
|
||||
*/
|
||||
public function __construct(FetchesHelpMenuQuestion $fetchesHelpMenuQuestion)
|
||||
{
|
||||
$this->fetchesHelpMenuQuestion = $fetchesHelpMenuQuestion;
|
||||
}
|
||||
|
||||
public function execute(Request $request){
|
||||
try {
|
||||
$query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1]);
|
||||
return $query;
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Processors;
|
||||
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuQuestion;
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuUserAnswerSelected;
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuUserAnswerSelectedList;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Classes\ValueObjects\Constants\QAType;
|
||||
|
||||
class FetchNextHelpMenuQuestionProcessor
|
||||
{
|
||||
/** @var FetchesHelpMenuQuestion */
|
||||
private $fetchesHelpMenuQuestion;
|
||||
|
||||
/** @var FetchesHelpMenuUserAnswerSelected */
|
||||
private $fetchesHelpMenuUserAnswerSelected;
|
||||
|
||||
/** @var FetchesHelpMenuUserAnswerSelectedList */
|
||||
private $fetchesHelpMenuUserAnswerSelectedList;
|
||||
/**
|
||||
* FetchNextHelpMenuQuestionProcessor constructor.
|
||||
* @param FetchesHelpMenuQuestion $fetchesHelpMenuQuestion
|
||||
* @param FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected
|
||||
* @param FetchesHelpMenuUserAnswerSelectedList $fetchesHelpMenuUserAnswerSelectedList
|
||||
*/
|
||||
public function __construct(FetchesHelpMenuQuestion $fetchesHelpMenuQuestion, FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected, FetchesHelpMenuUserAnswerSelectedList $fetchesHelpMenuUserAnswerSelectedList)
|
||||
{
|
||||
$this->fetchesHelpMenuQuestion = $fetchesHelpMenuQuestion;
|
||||
$this->fetchesHelpMenuUserAnswerSelected = $fetchesHelpMenuUserAnswerSelected;
|
||||
$this->fetchesHelpMenuUserAnswerSelectedList = $fetchesHelpMenuUserAnswerSelectedList;
|
||||
}
|
||||
|
||||
public function execute(Request $request){
|
||||
$isEnd = 0;
|
||||
$questionId = 0;
|
||||
$nextQuestionNumber = 0;
|
||||
$nextNestedQuestion = 0;
|
||||
$nextMainQuestion= 0;
|
||||
$currentQuestion = $request->question;
|
||||
$questionType = QAType::DEFAULT;
|
||||
$returnQuestion = null;
|
||||
|
||||
if ($currentQuestion && array_key_exists('id', $currentQuestion)) {
|
||||
$questionId = $currentQuestion['id'];
|
||||
$isEnd = $currentQuestion['is_end'];
|
||||
$questionType = $currentQuestion['question_type'];
|
||||
$nextNestedQuestion = $currentQuestion['next_nested_question'];
|
||||
$nextMainQuestion = $currentQuestion['next_main_question'];
|
||||
}
|
||||
if ($request->has('answerObj')) {
|
||||
$nextQuestionNumber = $request->answerObj['next_question_number'];
|
||||
}
|
||||
|
||||
if ($request->has('isPrevious')) {
|
||||
$userId = Auth::user()->id;
|
||||
$previousAnswer = $this->fetchesHelpMenuUserAnswerSelectedList->execute(['user_id' => $userId, 'order_by' => (object)['column' => 'id','DESC' => true]])[0];
|
||||
|
||||
//Get previous question
|
||||
$previousQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id' => $previousAnswer['question_id']]);
|
||||
$returnQuestion = $previousQuestion;
|
||||
}
|
||||
else{
|
||||
//Get next question
|
||||
$nextQuestion = null;
|
||||
$question_number = 0;
|
||||
if($nextQuestionNumber != 0){
|
||||
$question_number = $nextQuestionNumber;
|
||||
}
|
||||
else if($nextNestedQuestion != 0){
|
||||
$question_number = $nextNestedQuestion;
|
||||
}
|
||||
else {
|
||||
$question_number = $nextMainQuestion;
|
||||
}
|
||||
|
||||
if($isEnd){
|
||||
$returnQuestion = null;
|
||||
}
|
||||
else if($question_number != 0){
|
||||
$nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'question_number' => $question_number]);
|
||||
$returnQuestion = $nextQuestion;
|
||||
}
|
||||
else if (array_key_exists('id', $request->input('question'))) {
|
||||
$nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id_next' => $questionId, 'next_main_question' => null]);
|
||||
$returnQuestion = $nextQuestion;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnQuestion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Processors;
|
||||
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
use App\Classes\Modules\HelpMenu\Services\FetchesHelpMenuUserAnswerSelected;
|
||||
use App\Classes\Modules\Documents\Processors\UploadDocumentForHelpMenuProcessor;
|
||||
|
||||
|
||||
class SaveHelpMenuAnswerProcessor
|
||||
{
|
||||
/** @var FetchesHelpMenuUserAnswerSelected */
|
||||
private $fetchesHelpMenuUserAnswerSelected;
|
||||
|
||||
/** @var UploadDocumentForHelpMenuProcessor */
|
||||
private $uploadDocumentForHelpMenuProcessor;
|
||||
|
||||
/**
|
||||
* SaveHelpMenuAnswerProcessor constructor.
|
||||
* @param FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected
|
||||
* @param UploadDocumentForHelpMenuProcessor $uploadDocumentForHelpMenuProcessor
|
||||
*/
|
||||
public function __construct(FetchesHelpMenuUserAnswerSelected $fetchesHelpMenuUserAnswerSelected, UploadDocumentForHelpMenuProcessor $uploadDocumentForHelpMenuProcessor)
|
||||
{
|
||||
$this->fetchesHelpMenuUserAnswerSelected = $fetchesHelpMenuUserAnswerSelected;
|
||||
$this->uploadDocumentForHelpMenuProcessor = $uploadDocumentForHelpMenuProcessor;
|
||||
}
|
||||
|
||||
public function execute($userId, $questionId, $request){
|
||||
$filesUpload = $request->input('files');
|
||||
$answer = null;
|
||||
try{
|
||||
// $answer = $this->fetchesHelpMenuUserAnswerSelected->execute(['user_id' => $userId, 'question_id' => $questionId, 'order_by' => ['column' => 'id','DESC' => 1]]);
|
||||
$answer = $this->fetchesHelpMenuUserAnswerSelected->execute(['user_id' => $userId, 'question_id' => $questionId]);
|
||||
} catch (\Exception $exception){
|
||||
$answer = null;
|
||||
}
|
||||
|
||||
if(is_null($answer))
|
||||
{
|
||||
$answer = new QAUserAnswerSelected;
|
||||
}
|
||||
$answer->user_id = $userId;
|
||||
$answer->question_id = $questionId;
|
||||
if ($request->has('answerObj')) {
|
||||
$answer->answer_option_id = intval($request->answerObj['id']);
|
||||
}
|
||||
$answer->free_text_answer = $request->answer;
|
||||
$answer->save();
|
||||
|
||||
if($filesUpload){
|
||||
$result = $this->uploadDocumentForHelpMenuProcessor->execute($request, $answer);
|
||||
$newData = array_map(function ($item) {
|
||||
return [
|
||||
'document_id' => $item->document_id,
|
||||
'file_id' => $item->id,
|
||||
];
|
||||
}, $result);
|
||||
$answer->free_text_answer = json_encode($newData);
|
||||
$answer->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Services;
|
||||
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\QAQuestions;
|
||||
|
||||
class FetchesHelpMenuQuestion extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var QAQuestions */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesHelpMenuQuestion constructor.
|
||||
* @param QAQuestions $repository
|
||||
*/
|
||||
public function __construct(QAQuestions $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
|
||||
class FetchesHelpMenuUserAnswerSelected extends AbstractFetchRecord
|
||||
{
|
||||
|
||||
/** @var QAUserAnswerSelected */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesHelpMenuUserAnswerSelected constructor.
|
||||
* @param QAUserAnswerSelected $repository
|
||||
*/
|
||||
public function __construct(QAUserAnswerSelected $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractListRecord;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
|
||||
class FetchesHelpMenuUserAnswerSelectedList extends AbstractListRecord
|
||||
{
|
||||
|
||||
/** @var QAUserAnswerSelected */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* FetchesHelpMenuUserAnswerSelectedList constructor.
|
||||
* @param QAUserAnswerSelected $repository
|
||||
*/
|
||||
public function __construct(QAUserAnswerSelected $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Builder
|
||||
*/
|
||||
public function getRepository(): Builder
|
||||
{
|
||||
return $this->repository->newQuery();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\HelpMenu\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
|
||||
class CanFetchHelpMenuQuestionList extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
-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));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PerfexCRM\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CreatesPerfexCRMSupportTicket
|
||||
{
|
||||
/**
|
||||
* @param string $subject
|
||||
* @param string $department
|
||||
* @param int $contactid
|
||||
* @param int $userid
|
||||
* @return null|object
|
||||
* @throws MalformedRequestException
|
||||
*/
|
||||
public function execute(string $subject, string $department, int $contactid, int $userid) {
|
||||
try{
|
||||
$data = [
|
||||
'subject' => $subject,
|
||||
'department' => $department,
|
||||
'contactid' => $contactid,
|
||||
'userid' => $userid,
|
||||
];
|
||||
|
||||
$response = Http::asForm()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->post(config('perfexcrm.base_url').'/api/tickets',$data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
return (object) $data;
|
||||
}else{
|
||||
Log::error($response);
|
||||
return null;
|
||||
}
|
||||
}catch(\Exception $exception){
|
||||
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@ class UpdateConstantPostcodeLogic extends AbstractControllerLogic
|
||||
* @param UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
*/
|
||||
public function __construct(
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor)
|
||||
UpdatePostcodeSegmentProcessor $updatePostcodeSegmentProcessor
|
||||
)
|
||||
{
|
||||
$this->updatePostcodeSegmentProcessor = $updatePostcodeSegmentProcessor;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\ValueObjects\Constants;
|
||||
|
||||
final class QAType {
|
||||
|
||||
public const DEFAULT = 0;
|
||||
|
||||
public const MULTIPLE_CHOICES = 1;
|
||||
|
||||
public const FREE_TEXT = 2;
|
||||
|
||||
public const DOCUMENT_UPLOAD = 3;
|
||||
|
||||
public const ANSWER = 4;
|
||||
|
||||
public const TICKET_CRM = 5;
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\HelpMenu;
|
||||
|
||||
use App\Classes\Modules\HelpMenu\ControllersLogic\FetchHelpMenuQuestionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchHelpMenuQuestionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchHelpMenuQuestionLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchHelpMenuQuestionLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\HelpMenu;
|
||||
|
||||
use App\Classes\Modules\HelpMenu\ControllersLogic\UpdateHelpMenuNextQuestionLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateHelpMenuNextQuestionController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchQAQuestionListLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, UpdateHelpMenuNextQuestionLogic $logic): JsonResponse {
|
||||
return $logic->execute($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
|
||||
{
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class HelpMenuAnswerOptionsResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'display_text' => $this->display_text,
|
||||
'value' => $this->value,
|
||||
'order' => $this->order,
|
||||
'question_number' => $this->question_number,
|
||||
'next_question_number' => $this->next_question_number,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Models\QAQuestions;
|
||||
use App\Models\QAAnswerOptions;
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
|
||||
class HelpMenuQuestionResource extends JsonResource
|
||||
{
|
||||
/** @var integer */
|
||||
private $userId;
|
||||
|
||||
/** @var QAQuestions*/
|
||||
private $question;
|
||||
|
||||
public function __construct($question, $userId) {
|
||||
$this->question = $question;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if($this->question){
|
||||
$q = (object)$this->question;
|
||||
return [
|
||||
'id' => $q->id,
|
||||
'question_number' => $q->question_number,
|
||||
'question_text' => $q->question_text,
|
||||
'question_type' => $q->question_type,
|
||||
'question_answers' => HelpMenuAnswerOptionsResource::collection(QAAnswerOptions::where('question_number', $q->question_number)->get()),
|
||||
'questionnaire_set_id' => $q->questionnaire_set_id,
|
||||
'next_nested_question' => $q->next_nested_question,
|
||||
'next_main_question' => $q->next_main_question,
|
||||
'is_start' => $q->is_start,
|
||||
'is_end' => $q->is_end,
|
||||
'end_text' => $q->end_text,
|
||||
'order' => $q->order,
|
||||
'answer' => QAUserAnswerSelected::where('question_id', $q->id)->where('user_id', $this->userId)->first(),
|
||||
'questionnaire_answers' => $q->is_end ? HelpMenuQuestionnaireAnswersResource::collection(QAUserAnswerSelected::where('user_id', $this->userId)->get()) : null,
|
||||
];
|
||||
}
|
||||
else{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use App\Models\QAQuestions;
|
||||
|
||||
class HelpMenuQuestionnaireAnswersResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$question = QAQuestions::where('id', $this->question_id)->first();
|
||||
return [
|
||||
'question_text' => $question ? $question->question_text : null,
|
||||
'free_text_answer' => $this->free_text_answer
|
||||
];
|
||||
}
|
||||
}
|
||||
+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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
+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,69 +11,16 @@ 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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class QAAnswerOptions extends AbstractModel
|
||||
{
|
||||
protected $table = 'qa_answer_options';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class QAQuestionnaireSet extends AbstractModel
|
||||
{
|
||||
protected $table = 'qa_questionnaire_sets';
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class QAQuestions extends AbstractModel
|
||||
{
|
||||
protected $table = 'qa_questions';
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Documentable;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
/**
|
||||
* Class Contact
|
||||
* @package App\Models
|
||||
*/
|
||||
class QAUserAnswerSelected extends AbstractModel implements Documentable
|
||||
{
|
||||
protected $table = 'qa_user_answer_selected';
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function documents(): morphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'owner');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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,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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,6 @@ class CompanyTransformer extends TransformerAbstract
|
||||
/**
|
||||
* Include Contact
|
||||
*
|
||||
* @param Company $company
|
||||
* @return Item
|
||||
*/
|
||||
public function includeContact(Company $company): Item
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user