mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c70596e6bb | |||
| ebc3e588ca | |||
| 80471acc5b | |||
| ea08774111 | |||
| 4a1f05e62a | |||
| 840fb86192 | |||
| 7a171685f6 | |||
| 096e039ffb | |||
| 2319393758 | |||
| 85ba9d66d5 | |||
| 626dff6137 | |||
| 99efce22db | |||
| 4a9e89c752 | |||
| 39e3398f8e | |||
| 7db77d619b | |||
| 8f390311af | |||
| 6502957021 | |||
| d6ddf6d607 | |||
| b368b1c0d1 | |||
| a2ef3ed1b1 | |||
| e1b712ad10 | |||
| ddbfc5fdfd | |||
| 924d94796d | |||
| 92a38a96a0 | |||
| c8cdc5ff78 | |||
| 1cdd511f67 | |||
| f7d0fe117e | |||
| 4dede50156 | |||
| 0d555eedc9 | |||
| 7f73ec14a5 | |||
| 408397e20e | |||
| ef37f1ebbe | |||
| 33d922bb23 | |||
| 1b0f864921 | |||
| dfacae1a5d | |||
| caaab55e88 | |||
| 07d353d4bb | |||
| 823958504c | |||
| 4cb30ad7ab | |||
| 914e9a6f0f | |||
| 7b8eadd5d1 | |||
| 525e7a5dd1 | |||
| a3cad7816c | |||
| 2100c4a14a | |||
| 9d130e1531 | |||
| 893d10c7f6 | |||
| 0d090b4eaf | |||
| 68257952ab | |||
| 73801a5acd | |||
| 07a7901844 | |||
| 2c0eeab84e | |||
| 40c4a39927 | |||
| 91fcb76863 | |||
| 866df52e52 | |||
| b34d909a09 | |||
| 26b3e968e9 | |||
| 7b127b2cba | |||
| cac02b8ebe | |||
| 7488313a0e | |||
| 4370ba2f9c | |||
| 7589b5c553 | |||
| d8391fe479 | |||
| c01e8d6eb2 | |||
| 5aad5f1729 | |||
| 485a6e2e82 | |||
| 14a4c37fee | |||
| f27e0aa8c6 | |||
| 5c109d625c | |||
| a9910c5a12 | |||
| 4bee415d2d | |||
| 02f7adb1e9 | |||
| 039a6155ca | |||
| c8d806a51d | |||
| 4dbaf6a5dc | |||
| fcc0135843 | |||
| 4a922ac340 | |||
| c4d421db76 | |||
| 2816e80bee | |||
| 466e90a0af | |||
| 5e6ae2a905 |
+16
-16
@@ -96,24 +96,24 @@ database:
|
|||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
#mysql
|
#mysql
|
||||||
unit_test:
|
#unit_test:
|
||||||
stage: unit_test
|
# stage: unit_test
|
||||||
services:
|
# services:
|
||||||
- name: mysql:8.0
|
# - name: mysql:8.0
|
||||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
#dependencies:
|
#dependencies:
|
||||||
# - database
|
# - database
|
||||||
script:
|
# script:
|
||||||
- npm install # Install npm dependencies
|
# - npm install # Install npm dependencies
|
||||||
- gulp build # Build assets
|
# - gulp build # Build assets
|
||||||
- composer install
|
# - composer install
|
||||||
- cp .env.example .env
|
# - cp .env.example .env
|
||||||
- php artisan key:generate
|
# - php artisan key:generate
|
||||||
- php artisan migrate:fresh
|
# - php artisan migrate:fresh
|
||||||
- php artisan db:seed
|
# - php artisan db:seed
|
||||||
- php artisan test
|
# - php artisan test
|
||||||
rules:
|
# rules:
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\General\Eloquent\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class BillNo implements Filter
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $builder
|
||||||
|
* @param $value
|
||||||
|
* @return Builder|mixed
|
||||||
|
*/
|
||||||
|
public static function apply(Builder $builder, $value)
|
||||||
|
{
|
||||||
|
return $builder->where('bill_no', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
|||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||||
$query->where('type', $value)->whereIn('status', [0,1,2,3]);
|
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
||||||
})->whereHas('containers', function ($query){
|
})->whereHas('containers', function ($query){
|
||||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\General\Interfaces\Contactable;
|
use App\Classes\General\Interfaces\Contactable;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
@@ -17,6 +20,7 @@ use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -27,7 +31,8 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Address',
|
'title' => 'Created Address',
|
||||||
'message' => 'You have successfully created a new Address'
|
'message' => 'You have successfully created a new Address'
|
||||||
@@ -74,11 +79,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
@@ -90,16 +95,22 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||||
|
|
||||||
if($request->input('phone')){
|
if ($request->input('phone')) {
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('remark')){
|
if ($request->input('remark')) {
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||||
@@ -14,6 +17,7 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -23,7 +27,8 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Billing Address',
|
'title' => 'Created Billing Address',
|
||||||
'message' => 'You have successfully created a new Billing Address'
|
'message' => 'You have successfully created a new Billing Address'
|
||||||
@@ -60,11 +65,11 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||||
|
|
||||||
@@ -80,6 +85,14 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//load address with only owner address
|
||||||
|
|
||||||
|
/* return fractal()
|
||||||
|
->item($billingAddressInputed, new AddressTransformer())
|
||||||
|
->parseIncludes('Owner_address')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||||
@@ -17,7 +19,8 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Address',
|
'title' => 'Retrieved Address',
|
||||||
'message' => 'You have successfully retrieved a Address'
|
'message' => 'You have successfully retrieved a Address'
|
||||||
@@ -45,15 +48,22 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canFetchAddress->passes();
|
$this->canFetchAddress->passes();
|
||||||
|
|
||||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
|
||||||
|
//load address with no relationships
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($query));
|
return $this->resourceResponse(new AddressResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +21,8 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Addresses',
|
'title' => 'Retrieved Addresses',
|
||||||
'message' => 'You have successfully retrieved a list of Addresses'
|
'message' => 'You have successfully retrieved a list of Addresses'
|
||||||
@@ -45,17 +50,25 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListAddresses->passes();
|
$this->canListAddresses->passes();
|
||||||
|
|
||||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
|
//a collection of addresses with all incluides
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new AddressTransformer)
|
||||||
|
->parseIncludes('Owner_address')
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->parseIncludes('contact')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(AddressResource::collection($query));
|
return $this->collectionResponse(AddressResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
|
||||||
use App\Http\Resources\DistrictResource;
|
use App\Http\Resources\DistrictResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
|
||||||
use App\Http\Resources\StateResource;
|
use App\Http\Resources\StateResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|||||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
/** @var ResetsAddressesDefault */
|
/** @var ResetsAddressesDefault */
|
||||||
private $resetsAddressesDefault;
|
private $resetsAddressesDefault;
|
||||||
|
|
||||||
/** @var SetsAddressToDefault*/
|
/** @var SetsAddressToDefault */
|
||||||
private $setsAddressToDefault;
|
private $setsAddressToDefault;
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +65,15 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
|
||||||
|
$setAddress = $this->setsAddressToDefault->execute($address);
|
||||||
|
//no relationships needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($setAddress, new AddressTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\AddressType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Address',
|
'title' => 'Updated Address',
|
||||||
'message' => 'You have successfully updated the Address'
|
'message' => 'You have successfully updated the Address'
|
||||||
@@ -77,7 +79,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
@@ -90,18 +92,25 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->updatesAddress->execute($address, $object);
|
$address = $this->updatesAddress->execute($address, $object);
|
||||||
|
|
||||||
$address->contacts()->delete(); $address->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'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($request->input('remark')){
|
if ($request->input('remark')) {
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//only remark relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($address, new AddressTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Billplzs\Services;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
|
||||||
class CreatesBillplzBill
|
class CreatesBillplzBill
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ class CreatesBillplzBill
|
|||||||
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
$response = Http::withBasicAuth(config('billplz.api_key').':', '')->post(config('billplz.base_url').'/api/v3/bills', [
|
||||||
'collection_id' => config('billplz.collection_id'),
|
'collection_id' => config('billplz.collection_id'),
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $email,
|
'email' => App::environment('production') ? $email : 'development@cief-malaysia.com',
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'amount' => $this->finalizeAmount($amount),
|
'amount' => $this->finalizeAmount($amount),
|
||||||
'redirect_url' => route('online_payment.redirect'),
|
'redirect_url' => route('online_payment.redirect'),
|
||||||
|
|||||||
@@ -3,13 +3,16 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
use App\Classes\Modules\Companies\Services\ListsCompanies;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Http\Resources\CompanyResource;
|
use App\Transformers\CompanyTransformer;
|
||||||
use ErrorException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Spatie\Fractalistic\ArraySerializer;
|
||||||
|
|
||||||
class ListCompaniesLogic extends AbstractControllerLogic
|
class ListCompaniesLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -45,16 +48,24 @@ class ListCompaniesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
||||||
return $this->collectionResponse(CompanyResource::collection($query));
|
// return $this->collectionResponse(CompanyResource::collection($query));
|
||||||
|
|
||||||
|
return fractal()
|
||||||
|
->parseIncludes(['owner'])
|
||||||
|
->collection($query, new CompanyTransformer(), "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
namespace App\Classes\Modules\Companies\ControllersLogic;
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
use App\Classes\Modules\Companies\Services\ListsCompanyModules;
|
||||||
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
||||||
use App\Http\Resources\CompanyModuleResource;
|
use App\Http\Resources\CompanyModuleResource;
|
||||||
|
use App\Transformers\CompanyTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +21,8 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Company Moduels',
|
'title' => 'Retrieved Company Moduels',
|
||||||
'message' => 'You have successfully retrieved a list of Companies'
|
'message' => 'You have successfully retrieved a list of Companies'
|
||||||
@@ -45,15 +50,26 @@ class ListCompanyModulesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListCompanies->passes();
|
$this->canListCompanies->passes();
|
||||||
|
|
||||||
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
$query = $this->listsCompanyModules->execute($this->listsCompanyModules->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
|
/*include all relationships*/
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new CompanyTransformer)
|
||||||
|
->parseIncludes('company')
|
||||||
|
->parseIncludes('contact')
|
||||||
|
->parseIncludes('remarks')
|
||||||
|
->parseIncludes('address')
|
||||||
|
->parseIncludes('billingAddress')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
return $this->collectionResponse(CompanyModuleResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
|||||||
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
||||||
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
||||||
use App\Http\Resources\ContactResource;
|
use App\Http\Resources\ContactResource;
|
||||||
|
use App\Transformers\ContactTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -63,6 +64,13 @@ class UpdateContactLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->updatesContact->execute($query, $object);
|
$query = $this->updatesContact->execute($query, $object);
|
||||||
|
|
||||||
|
/*uniformity*/
|
||||||
|
/* return fractal()
|
||||||
|
->item($query, new ContactTransformer())
|
||||||
|
->parseIncludes('remark')
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new ContactResource($query));
|
return $this->resourceResponse(new ContactResource($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\Modules\Orders\Services\CancelsOrder;
|
|||||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||||
use App\Http\Resources\DeliveryOrderResource;
|
use App\Http\Resources\DeliveryOrderResource;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
|
use App\Transformers\DeliveryOrderTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -52,6 +53,14 @@ class CancelDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
/** @var Order $order */
|
/** @var Order $order */
|
||||||
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
$order = $this->fetchesOrder->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
$order = $this->cancelsOrder->execute($order);
|
||||||
|
|
||||||
|
//no relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->item($order, new DeliveryOrderTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
return $this->resourceResponse(new DeliveryOrderResource($this->cancelsOrder->execute($order)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,12 @@ class CreateDeliveryOrderLogic extends AbstractControllerLogic
|
|||||||
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
$packageObject = new PackageObject($request->input('packing_list.type'), $request->input('packing_list.description'), (float) 1, (float) 1, (float) 1, $request->input('packing_list.weight'), (float) $request->input('packing_list.quantity'), ApprovalStatus::APPROVED);
|
||||||
$this->createsPackage->execute($packageObject, $packingList);
|
$this->createsPackage->execute($packageObject, $packingList);
|
||||||
|
|
||||||
|
//add relationship to order
|
||||||
|
/* return fractal()
|
||||||
|
->item($order, new DeliveryOrderTransformer())
|
||||||
|
->parseIncludes(['sender_address', 'delivery_address', 'sender_address.contacts', 'delivery_address.contacts', 'sender_address.remarks', 'delivery_address.remarks', 'packing_list', 'packing_list.packages'])
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->resourceResponse(new DeliveryOrderResource($order));
|
return $this->resourceResponse(new DeliveryOrderResource($order));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ class ListOrdersLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
||||||
|
|
||||||
|
|
||||||
|
//no relationship needed
|
||||||
|
/* return fractal()
|
||||||
|
->collection($query, new DeliveryOrderTransformer)
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\AccessForbiddenException;
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
|
use App\Classes\Exceptions\RequestValidationException;
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||||
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
||||||
@@ -12,6 +15,7 @@ use App\Transformers\DocumentTransformer;
|
|||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +25,8 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Document',
|
'title' => 'Retrieved Document',
|
||||||
'message' => 'You have successfully retrieved a list of Document'
|
'message' => 'You have successfully retrieved a list of Document'
|
||||||
@@ -49,24 +54,29 @@ class ListDocumentLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListDocuments->passes();
|
$this->canListDocuments->passes();
|
||||||
|
|
||||||
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
||||||
|
|
||||||
return $this->collectionResponse(DocumentResource::collection($query));
|
$data = fractal()
|
||||||
|
->parseIncludes(['owner'])
|
||||||
|
->collection($query, new DocumentTransformer, "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* return fractal()
|
|
||||||
->collection($query, new DocumentTransformer)
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||||
|
|
||||||
|
use App\Classes\Exceptions\MalformedRequestException;
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
use App\Classes\General\Interfaces\DataTransferObject;
|
||||||
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
|
use App\Classes\Modules\Documents\Services\ConvertsBase64ToFile;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ class DocumentObject implements DataTransferObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function getFiles(): array
|
public function getFiles(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ class ConvertsBase64ToFile
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
private function generateFile(FileObject $file, string $suffix = '') {
|
private function generateFile(FileObject $file, string $suffix = ''): string
|
||||||
|
{
|
||||||
|
|
||||||
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
|||||||
'DocNo',
|
'DocNo',
|
||||||
'DocDate',
|
'DocDate',
|
||||||
'DebtorCode',
|
'DebtorCode',
|
||||||
|
'DebtorCode',
|
||||||
'ShipInfo',
|
'ShipInfo',
|
||||||
'AccNo',
|
'AccNo',
|
||||||
'DetailDescription',
|
'DetailDescription',
|
||||||
@@ -126,6 +127,7 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading
|
|||||||
$transaction->created_at->format('m/d/Y H:m'),
|
$transaction->created_at->format('m/d/Y H:m'),
|
||||||
$company->debtor,
|
$company->debtor,
|
||||||
$order->reference,
|
$order->reference,
|
||||||
|
$order->reference,
|
||||||
'500-0000',
|
'500-0000',
|
||||||
'X1 Freight Service Charge',
|
'X1 Freight Service Charge',
|
||||||
$furtherDescription,
|
$furtherDescription,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Http\Resources\OrderResource;
|
use App\Http\Resources\OrderResource;
|
||||||
|
use App\Transformers\AddressTransformer;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
@@ -39,6 +40,12 @@ class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$address = $this->approveChangeOrderAddressProcessor->execute($request);
|
$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));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,20 @@ use App\Classes\Modules\Orders\Services\ListsOrders;
|
|||||||
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
||||||
use App\Classes\ValueObjects\Constants\OrderType;
|
use App\Classes\ValueObjects\Constants\OrderType;
|
||||||
use App\Http\Resources\OrderV2Resource;
|
use App\Http\Resources\OrderV2Resource;
|
||||||
|
use App\Transformers\DocumentTransformer;
|
||||||
|
use App\Transformers\OrderTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
|
||||||
class ListOrdersV2Logic extends AbstractControllerLogic
|
class ListOrdersV2Logic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Orders',
|
'title' => 'Retrieved Orders',
|
||||||
'message' => 'You have successfully retrieved a list of Orders'
|
'message' => 'You have successfully retrieved a list of Orders'
|
||||||
@@ -41,16 +45,23 @@ class ListOrdersV2Logic extends AbstractControllerLogic
|
|||||||
$this->listsOrders = $listsOrders;
|
$this->listsOrders = $listsOrders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListOrders->passes();
|
$this->canListOrders->passes();
|
||||||
|
|
||||||
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::SHARED_CONTAINER, OrderType::DEDICATED_CONTAINER]]));
|
||||||
|
|
||||||
return $this->collectionResponse(OrderV2Resource::collection($query));
|
|
||||||
|
// return $this->collectionResponse(OrderV2Resource::collection($query));
|
||||||
|
|
||||||
|
return fractal()
|
||||||
|
->parseIncludes(['remarks', 'warehouse', 'address'])
|
||||||
|
->collection($query, new OrderTransformer(), "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -56,6 +57,13 @@ class AssignPackingListContainerLogic extends AbstractControllerLogic
|
|||||||
$container->packingLists()->attach($packing_list_item);
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
|
|
||||||
} catch (\Exception $exception){
|
} catch (\Exception $exception){
|
||||||
|
|||||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -19,7 +20,8 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Container',
|
'title' => 'Updated Container',
|
||||||
'message' => 'You have successfully updated the Container'
|
'message' => 'You have successfully updated the Container'
|
||||||
@@ -51,10 +53,16 @@ class CompleteContainerLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
$query = $this->updatesContainerStatus->execute($container, ApprovalStatus::COMPLETED);
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
|||||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||||
|
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -70,6 +71,11 @@ class CreateContainerLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->createsContainer->execute($object, $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]));
|
$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));
|
return $this->resourceResponse(new ContainerResource($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -8,6 +8,7 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
|||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -18,7 +19,8 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Container Remark',
|
'title' => 'Created Container Remark',
|
||||||
'message' => 'You have successfully created a new Container Remark'
|
'message' => 'You have successfully created a new Container Remark'
|
||||||
@@ -50,7 +52,7 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
@@ -59,6 +61,12 @@ class CreateContainerRemarkLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->createRemarkProcessor->execute($container, $object);
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-9
@@ -17,6 +17,7 @@ use App\Classes\ValueObjects\Constants\TransportType;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -28,7 +29,8 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Container',
|
'title' => 'Created Container',
|
||||||
'message' => 'You have successfully created a new Container'
|
'message' => 'You have successfully created a new Container'
|
||||||
@@ -41,7 +43,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
|||||||
/** @var FetchesPackingList */
|
/** @var FetchesPackingList */
|
||||||
private $fetchesPackingList;
|
private $fetchesPackingList;
|
||||||
|
|
||||||
/** @var FetchesCompanyModule */
|
/** @var FetchesCompanyModule */
|
||||||
private $fetchesCompanyModule;
|
private $fetchesCompanyModule;
|
||||||
|
|
||||||
/** @var CreatesPackingList */
|
/** @var CreatesPackingList */
|
||||||
@@ -54,12 +56,12 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
|||||||
private $createsSchedule;
|
private $createsSchedule;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CanCreateContainer $canCreateContainer,
|
CanCreateContainer $canCreateContainer,
|
||||||
FetchesPackingList $fetchesPackingList,
|
FetchesPackingList $fetchesPackingList,
|
||||||
FetchesCompanyModule $fetchesCompanyModule,
|
FetchesCompanyModule $fetchesCompanyModule,
|
||||||
CreatesContainer $createsContainer,
|
CreatesContainer $createsContainer,
|
||||||
CreatesTransport $createsTransport,
|
CreatesTransport $createsTransport,
|
||||||
CreatesSchedule $createsSchedule
|
CreatesSchedule $createsSchedule
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->canCreateContainer = $canCreateContainer;
|
$this->canCreateContainer = $canCreateContainer;
|
||||||
@@ -77,7 +79,7 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$object = new ContainerObject(
|
$object = new ContainerObject(
|
||||||
$request->input('container_reference'),
|
$request->input('container_reference'),
|
||||||
@@ -104,9 +106,15 @@ class CreateLoadContainerLogic extends AbstractControllerLogic
|
|||||||
Carbon::parse($request->input('etd')),
|
Carbon::parse($request->input('etd')),
|
||||||
Carbon::parse($request->input('eta')),
|
Carbon::parse($request->input('eta')),
|
||||||
ApprovalStatus::APPROVED
|
ApprovalStatus::APPROVED
|
||||||
);
|
);
|
||||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanFetchContainer;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +18,8 @@ class FetchContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Container',
|
'title' => 'Retrieved Container',
|
||||||
'message' => 'You have successfully retrieved a Container'
|
'message' => 'You have successfully retrieved a Container'
|
||||||
@@ -48,12 +50,18 @@ class FetchContainerLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canFetchContainer->passes();
|
$this->canFetchContainer->passes();
|
||||||
|
|
||||||
$query = $this->fetchesContainer->execute(['id' => $request->route('id'), 'with_packing_lists' => true]);
|
$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));
|
return $this->resourceResponse(new ContainerResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -9,6 +9,7 @@ use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainer
|
|||||||
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;
|
||||||
|
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -19,7 +20,8 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Containers',
|
'title' => 'Retrieved Containers',
|
||||||
'message' => 'You have successfully retrieved a list of Containers'
|
'message' => 'You have successfully retrieved a list of Containers'
|
||||||
@@ -52,11 +54,16 @@ class InboundCustomClearedLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$query = $this->fetchInboundCustomCleared->execute();
|
$query = $this->fetchInboundCustomCleared->execute();
|
||||||
|
|
||||||
|
//no relations required
|
||||||
|
/* return fractal()
|
||||||
|
->item($query, new ContainerTransformer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
||||||
|
|
||||||
return $this->collectionResponse(ContainerResource::collection($query));
|
return $this->collectionResponse(ContainerResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-5
@@ -3,10 +3,14 @@
|
|||||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
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\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +21,8 @@ class ListContainersLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Containers',
|
'title' => 'Retrieved Containers',
|
||||||
'message' => 'You have successfully retrieved a list of Containers'
|
'message' => 'You have successfully retrieved a list of Containers'
|
||||||
@@ -45,16 +50,22 @@ class ListContainersLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListContainers->passes();
|
$this->canListContainers->passes();
|
||||||
|
|
||||||
$query = $this->listsContainers->execute($this->listsContainers->deserializeFilters($request->input('filters')));
|
$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));
|
return $this->collectionResponse(ContainerResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-4
@@ -10,6 +10,7 @@ use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -20,7 +21,8 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Reschedule Container',
|
'title' => 'Reschedule Container',
|
||||||
'message' => 'You have successfully Reschedule Container'
|
'message' => 'You have successfully Reschedule Container'
|
||||||
@@ -54,7 +56,7 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
@@ -68,12 +70,17 @@ class RescheduleContainerLogic extends AbstractControllerLogic
|
|||||||
Carbon::parse($request->input('etd')),
|
Carbon::parse($request->input('etd')),
|
||||||
Carbon::parse($request->input('eta')),
|
Carbon::parse($request->input('eta')),
|
||||||
ApprovalStatus::APPROVED
|
ApprovalStatus::APPROVED
|
||||||
);
|
);
|
||||||
$schedule = $this->createsSchedule->execute($transport, $scheduleObject);
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
|
|
||||||
} catch (\Exception $exception){
|
} catch (\Exception $exception) {
|
||||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-5
@@ -3,12 +3,16 @@
|
|||||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;
|
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\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\UpdatesContainer;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanUpdateContainer;
|
||||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
use App\Classes\Modules\PackingLists\DataTransferObjects\ContainerObject;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -19,7 +23,8 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Container',
|
'title' => 'Updated Container',
|
||||||
'message' => 'You have successfully updated the Container'
|
'message' => 'You have successfully updated the Container'
|
||||||
@@ -52,11 +57,11 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
* @throws AccessForbiddenException
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
@@ -74,6 +79,12 @@ class UpdateContainerLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->updatesContainer->execute($container, $object);
|
$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));
|
return $this->resourceResponse(new ContainerResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
use App\Classes\Modules\Transports\Services\UpdatesDispatchDateTransport;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +18,8 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Dispatch Date Container',
|
'title' => 'Updated Dispatch Date Container',
|
||||||
'message' => 'You have successfully updated the Dispatch Date Container'
|
'message' => 'You have successfully updated the Dispatch Date Container'
|
||||||
@@ -49,11 +51,18 @@ class UpdateDispatchDateContainerLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
$transport = $container->transports()->first();
|
$transport = $container->transports()->first();
|
||||||
$query = $this->updatesDispatchDateTransport->execute($transport, Carbon::parse($request->input('dispatch_date')));
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -6,6 +6,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
use App\Classes\Modules\Transports\Services\UpdatesDropDateTransport;
|
||||||
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||||
use App\Http\Resources\ContainerResource;
|
use App\Http\Resources\ContainerResource;
|
||||||
|
use App\Transformers\ContainerTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,7 +18,8 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Drop Date Container',
|
'title' => 'Updated Drop Date Container',
|
||||||
'message' => 'You have successfully updated the Drop Date Container'
|
'message' => 'You have successfully updated the Drop Date Container'
|
||||||
@@ -49,11 +51,17 @@ class UpdateDropDateContainerLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
$container = $this->fetchesContainer->execute(['id' => $request->route('id')]);
|
||||||
$transport = $container->transports()->first();
|
$transport = $container->transports()->first();
|
||||||
$query = $this->updatesDropDateTransport->execute($transport, Carbon::parse($request->input('drop_date')));
|
$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));
|
return $this->resourceResponse(new ContainerResource($container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -14,6 +14,7 @@ use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
|
|
||||||
use App\Http\Resources\DeliverPackingListResource;
|
use App\Http\Resources\DeliverPackingListResource;
|
||||||
|
use App\Transformers\DeliverPackingListTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Deliver PackingList',
|
'title' => 'Created Deliver PackingList',
|
||||||
'message' => 'You have successfully created a new Deliver PackingList'
|
'message' => 'You have successfully created a new Deliver PackingList'
|
||||||
@@ -60,7 +62,7 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
|||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @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')]);
|
$company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||||
$packing_list_id = $request->input('packing_list_id');
|
$packing_list_id = $request->input('packing_list_id');
|
||||||
@@ -82,6 +84,12 @@ class CreateDeliverPackingListLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$deliverPackingList->packing_list_owner()->sync($packing_list_id);
|
$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));
|
return $this->resourceResponse(new DeliverPackingListResource($deliverPackingList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|||||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
||||||
use App\Http\Resources\PackingListNullOrderResource;
|
use App\Http\Resources\PackingListNullOrderResource;
|
||||||
use App\Http\Resources\PackingListResource;
|
use App\Http\Resources\PackingListResource;
|
||||||
|
use App\Transformers\PackageListTransformer;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Spatie\Fractalistic\ArraySerializer;
|
||||||
|
|
||||||
class ListPackingListsLogic extends AbstractControllerLogic
|
class ListPackingListsLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -18,7 +20,8 @@ class ListPackingListsLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved PackingLists',
|
'title' => 'Retrieved PackingLists',
|
||||||
'message' => 'You have successfully retrieved a list of PackingLists'
|
'message' => 'You have successfully retrieved a list of PackingLists'
|
||||||
@@ -48,13 +51,22 @@ class ListPackingListsLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws ErrorException
|
* @throws ErrorException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request) : JsonResponse
|
public function logic(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$this->canListPackingLists->passes();
|
$this->canListPackingLists->passes();
|
||||||
|
|
||||||
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
return $this->collectionResponse(PackingListResource::collection($query));
|
return fractal()
|
||||||
|
->parseIncludes(['transport', 'packages'])
|
||||||
|
->collection($query, new PackageListTransformer(), "data")
|
||||||
|
->serializeWith(new ArraySerializer())
|
||||||
|
->respond(200, [], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
|
||||||
|
//return $this->collectionResponse(PackingListResource::collection($query));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -51,7 +51,7 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
|||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
|
|
||||||
$packingList = $container->packingLists()->random();
|
$packingList = $container->packingLists()->first();
|
||||||
|
|
||||||
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
$trackingRequest = $this->fetchesDataFRomYDPortal->clientRequest('http://www.yd-wl.com/api/ApiTracking.ashx', 'GET', [
|
||||||
'trakingno' => $packingList->reference
|
'trakingno' => $packingList->reference
|
||||||
@@ -108,6 +108,8 @@ class FetchContainersUpdatesFromYdPortalProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump($delayDate, $unstuffingDate);
|
||||||
|
|
||||||
if($delayDate){
|
if($delayDate){
|
||||||
$delayDate = $delayDate->addDays(2);
|
$delayDate = $delayDate->addDays(2);
|
||||||
$transport = $container->transports()->first();
|
$transport = $container->transports()->first();
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ class TransactionToPerfexCRMProcessor
|
|||||||
PerfexCRMProjectStatus::IN_PROGRESS,
|
PerfexCRMProjectStatus::IN_PROGRESS,
|
||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
PerfexCRMTasks::TASK_1,
|
// PerfexCRMTasks::TASK_1,
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
// PerfexCRMTasks::TASK_POST_PAYMENT_1,
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
// PerfexCRMTasks::TASK_POST_PAYMENT_2,
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
// PerfexCRMTasks::TASK_POST_PAYMENT_3,
|
||||||
PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
// PerfexCRMTasks::TASK_POST_PAYMENT_4,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
use App\Classes\Modules\Transactions\Services\FetchesGroup;
|
||||||
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
||||||
|
use App\Classes\Modules\Transactions\Services\DeletesGroup;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Http\Resources\GroupResource;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -24,14 +23,11 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var UpdatesTransactionStatus */
|
|
||||||
private $updatesTransactionStatus;
|
|
||||||
|
|
||||||
/** @var FetchesGroup */
|
/** @var FetchesGroup */
|
||||||
private $fetchesGroup;
|
private $fetchesGroup;
|
||||||
|
|
||||||
/** @var DeletesTransaction */
|
/** @var DeletesGroup */
|
||||||
private $deletesTransaction;
|
private $deletesGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteGroupLogic constructor.
|
* DeleteGroupLogic constructor.
|
||||||
@@ -39,11 +35,10 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
|||||||
* @param FetchesGroup $fetchesGroup
|
* @param FetchesGroup $fetchesGroup
|
||||||
* @param DeletesTransaction $deletesTransaction
|
* @param DeletesTransaction $deletesTransaction
|
||||||
*/
|
*/
|
||||||
public function __construct(updatesTransactionStatus $updatesTransactionStatus, FetchesGroup $fetchesGroup, DeletesTransaction $deletesTransaction)
|
public function __construct(FetchesGroup $fetchesGroup, DeletesGroup $deletesGroup)
|
||||||
{
|
{
|
||||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
|
||||||
$this->fetchesGroup = $fetchesGroup;
|
$this->fetchesGroup = $fetchesGroup;
|
||||||
$this->deletesTransaction = $deletesTransaction;
|
$this->deletesGroup = $deletesGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,19 +50,9 @@ class DeleteGroupLogic extends AbstractControllerLogic
|
|||||||
{
|
{
|
||||||
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
$items = $group->transactions()->get();
|
$this->deletesGroup->execute($group);
|
||||||
|
|
||||||
foreach($items as $item) {
|
return $this->response([]);
|
||||||
$bill = $item;
|
|
||||||
$payment = $bill->owner;
|
|
||||||
$group->transactions()->detach($bill->id);
|
|
||||||
$this->updatesTransactionStatus->execute($payment, ApprovalStatus::APPROVED);
|
|
||||||
$this->deletesTransaction->execute($bill);
|
|
||||||
}
|
|
||||||
|
|
||||||
$group->delete();
|
|
||||||
|
|
||||||
return $this->resourceResponse(new GroupResource($group));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\Transactions\ControllersLogic;
|
|||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
use App\Classes\Modules\Transactions\Services\ListsGroups;
|
||||||
use App\Http\Resources\GroupResource;
|
use App\Http\Resources\GroupResource;
|
||||||
|
use App\Transformers\GroupTransformer;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -22,7 +23,8 @@ class ListGroupsLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Groups',
|
'title' => 'Retrieved Groups',
|
||||||
'message' => 'You have successfully retrieved a list of groups'
|
'message' => 'You have successfully retrieved a list of groups'
|
||||||
@@ -32,10 +34,15 @@ class ListGroupsLogic extends AbstractControllerLogic
|
|||||||
/** @var ListsGroups */
|
/** @var ListsGroups */
|
||||||
private $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')));
|
$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));
|
return $this->collectionResponse(GroupResource::collection($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||||
|
|
||||||
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
|
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||||
|
use App\Http\Resources\BookingResource;
|
||||||
|
use App\Http\Resources\MappableTransactionResource;
|
||||||
|
use App\Http\Resources\TransactionResource;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ListMappableTransactionsLogic extends AbstractControllerLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function notification():array {
|
||||||
|
return [
|
||||||
|
'title' => 'Retrieved Transactions',
|
||||||
|
'message' => 'You have successfully retrieved a list of transactions'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** @var ListsTransactions */
|
||||||
|
private $listsTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ListTransactionsLogic constructor.
|
||||||
|
* @param ListsTransactions $listsTransactions
|
||||||
|
*/
|
||||||
|
public function __construct(ListsTransactions $listsTransactions)
|
||||||
|
{
|
||||||
|
$this->listsTransactions = $listsTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function logic(Request $request) : JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
|
return $this->collectionResponse(MappableTransactionResource::collection($query));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -32,7 +32,8 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification():array {
|
protected function notification(): array
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
'title' => 'Update Group Transaction',
|
'title' => 'Update Group Transaction',
|
||||||
'message' => 'You have successfully updated this Group Transaction'
|
'message' => 'You have successfully updated this Group Transaction'
|
||||||
@@ -86,7 +87,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
|||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @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')]);
|
$group = $this->fetchesGroup->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
|||||||
// $group->transactions()->update(['amount' => DB::raw('(original_amount * (1 / currency_rate)) + service_charge + tax')]);
|
// $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();
|
$constant = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $supplier->id)->first();
|
||||||
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
$serviceCharge = $this->calculatesTransactionServiceCharge->execute($transaction->original_amount, $rate, $constant);
|
||||||
@@ -169,7 +170,7 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$object = new DocumentObject(
|
$object = new DocumentObject(
|
||||||
DocumentType::CURRENCY_VENDOR_ORDER,
|
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,
|
ApprovalStatus::COMPLETED,
|
||||||
'currency_vendor_order'
|
'currency_vendor_order'
|
||||||
@@ -179,6 +180,11 @@ class UpdateGroupLogic extends AbstractControllerLogic
|
|||||||
$document = $this->createsDocument->execute($group, $object);
|
$document = $this->createsDocument->execute($group, $object);
|
||||||
$this->createsFile->execute($document, $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));
|
return $this->resourceResponse(new GroupResource($group));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use App\Models\Wallet;
|
|||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromVTPortalProcessor;
|
||||||
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
use App\Classes\Modules\Orders\Processors\UpdateDoFromYDPortalProcessor;
|
||||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class CreatePaymentTransactionProcessor
|
class CreatePaymentTransactionProcessor
|
||||||
{
|
{
|
||||||
@@ -87,7 +88,8 @@ class CreatePaymentTransactionProcessor
|
|||||||
public function execute(Transaction $invoice, $payment_method, $bank_code)
|
public function execute(Transaction $invoice, $payment_method, $bank_code)
|
||||||
{
|
{
|
||||||
$amount = $invoice->amount;
|
$amount = $invoice->amount;
|
||||||
$company_module = $invoice->owner()->first()->owner()->first()->companyModule()->first();
|
Log::info($invoice->owner);
|
||||||
|
$company_module = $invoice->owner->owner->companyModule()->first();
|
||||||
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
$approvalStatus = ApprovalStatus::PENDING_SUBMISSION;
|
||||||
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
$billNumber = $this->generatesTransactionBillNumber->execute('PYMT-');
|
||||||
$payment_reference = null;
|
$payment_reference = null;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Transactions\Services;
|
||||||
|
|
||||||
|
use App\Classes\General\Eloquent\AbstractDeleteRecord;
|
||||||
|
use App\Models\Group;
|
||||||
|
|
||||||
|
class DeletesGroup extends AbstractDeleteRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Group $model
|
||||||
|
* @return mixed
|
||||||
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
|
*/
|
||||||
|
public function execute(Group $model) {
|
||||||
|
return $this->handler($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Modules\Transactions\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Classes\General\Eloquent\AbstractFetchRecord;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use App\Models\Group;
|
||||||
|
|
||||||
|
class FetchesGroup extends AbstractFetchRecord
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var Transaction */
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FetchesTransaction constructor.
|
||||||
|
* @param Transaction $repository
|
||||||
|
*/
|
||||||
|
public function __construct(Group $repository)
|
||||||
|
{
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Builder
|
||||||
|
*/
|
||||||
|
public function getRepository(): Builder
|
||||||
|
{
|
||||||
|
return $this->repository->newQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ namespace App\Classes\Notifications;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Models\PackingList;
|
use App\Models\PackingList;
|
||||||
use App\Models\PasswordReset;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -39,7 +38,7 @@ class InvoiceIssuedEmail extends AbstractEmail
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
|
->subject('Att: '.$this->user->name.' - Invoice for order no.'. $this->packingList->owner->reference)
|
||||||
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
|
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
|
||||||
'as' => 'name.pdf',
|
'as' => 'name.pdf',
|
||||||
'mime' => 'application/pdf',
|
'mime' => 'application/pdf',
|
||||||
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
|
])->view('emails.shipment.invoice', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Models\PackingList;
|
|||||||
use App\Models\PasswordReset;
|
use App\Models\PasswordReset;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ShipmentDepartureEmail extends AbstractEmail
|
class ShipmentDepartureEmail extends AbstractEmail
|
||||||
{
|
{
|
||||||
@@ -42,7 +43,7 @@ class ShipmentDepartureEmail extends AbstractEmail
|
|||||||
|
|
||||||
return (new MailMessage)
|
return (new MailMessage)
|
||||||
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
|
->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference)
|
||||||
->attach(Storage::disk('documents')->get($invoiceDocument->file->file_info->original->file), [
|
->attach(Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file), [
|
||||||
'as' => 'name.pdf',
|
'as' => 'name.pdf',
|
||||||
'mime' => 'application/pdf',
|
'mime' => 'application/pdf',
|
||||||
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
|
])->bcc(['email_test@cief-malaysia.com'])->view('emails.shipment.ETD', ['user' => $this->user, 'packingList' => $this->packingList]);
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ class FixBillplzFailedCallbackPayment extends Command
|
|||||||
{
|
{
|
||||||
ini_set('memory_limit', '-1');
|
ini_set('memory_limit', '-1');
|
||||||
|
|
||||||
$this->info(Carbon::now() . ' : Fix failled callback from billplz cron started.');
|
|
||||||
$this->outputArray = [];
|
$this->outputArray = [];
|
||||||
$start = new Carbon();
|
$start = new Carbon();
|
||||||
|
|
||||||
@@ -85,6 +84,11 @@ class FixBillplzFailedCallbackPayment extends Command
|
|||||||
|
|
||||||
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
$transactions = Transaction::where('type', TransactionType::PAYMENT)->where('payment_method', PaymentMethodType::PAYMENT_GATEWAY)->whereNotIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get();
|
||||||
$totalTransactions = count($transactions);
|
$totalTransactions = count($transactions);
|
||||||
|
|
||||||
|
if ($totalTransactions) {
|
||||||
|
$this->info(Carbon::now() . ' : Fix failled callback from billplz cron started.');
|
||||||
|
}
|
||||||
|
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
$totalAmount = 0;
|
$totalAmount = 0;
|
||||||
foreach ($transactions as $transaction){
|
foreach ($transactions as $transaction){
|
||||||
@@ -180,6 +184,9 @@ class FixBillplzFailedCallbackPayment extends Command
|
|||||||
$end = new Carbon();
|
$end = new Carbon();
|
||||||
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
||||||
|
|
||||||
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
if ($totalTransactions) {
|
||||||
|
$this->info(Carbon::now() . ' : Done Billplz Failled Callback. ElapsedTime: ' . $elapsedTime . '. Total: ' . $totalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('billplz-failed-callback:fix')
|
$schedule->command('billplz-failed-callback:fix')
|
||||||
->dailyAt('00:00')
|
->dailyAt('00:00')
|
||||||
->withoutOverlapping()
|
->withoutOverlapping()
|
||||||
->appendOutputTo (storage_path().'/logs/dix_failed_callback_from_billplz.log');
|
->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,21 +55,31 @@ class MonthlyReportController
|
|||||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
||||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
||||||
|
|
||||||
$receivedCbm = Package::warehouseReceiveList()->whereHas('deliveryTransports', function ($transport) use ($from, $to) {
|
/* $receivedCbm = Package::warehouseReceiveList()->whereHas('deliveryTransports', function ($transport) use ($from, $to) {
|
||||||
return $transport->whereBetween('drop_date', [$from, $to]);
|
return $transport->whereBetween('drop_date', [$from, $to]);
|
||||||
})->get()->sum(function($package){
|
})->get()->sum(function($package){
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
});*/
|
||||||
});
|
|
||||||
|
|
||||||
|
$receivedCbm = Package::with('deliveryTransports')
|
||||||
|
->warehouseReceiveList()
|
||||||
|
->whereHas('deliveryTransports', function ($transport) use ($from, $to) {
|
||||||
|
return $transport->whereBetween('drop_date', [$from, $to]);
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->sum(function ($package) {
|
||||||
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
|
});
|
||||||
|
|
||||||
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
|
||||||
|
|
||||||
$customers = $containers->flatMap(function ($container) {
|
$customers = $containers->flatMap(function ($container) {
|
||||||
return $container->companyModules;
|
return $container->companyModules;
|
||||||
})->unique();
|
})->unique()->count();
|
||||||
|
|
||||||
$orders = $containers->flatMap(function ($container) {
|
$orders = $containers->flatMap(function ($container) {
|
||||||
return $container->orders;
|
return $container->orders;
|
||||||
})->unique();
|
})->unique()->count();
|
||||||
|
|
||||||
$packages = $this->getPackages($from, $to);
|
$packages = $this->getPackages($from, $to);
|
||||||
|
|
||||||
@@ -84,12 +94,12 @@ class MonthlyReportController
|
|||||||
return $packingList->packages;
|
return $packingList->packages;
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
$totalCbm = $packages->sum(function($package){
|
$totalCbm = $packages->sum(function ($package) {
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
});
|
});
|
||||||
|
|
||||||
$newCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->count();
|
$newCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->count();
|
||||||
$newConvertedCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->whereHas('orders', function($order){
|
$newConvertedCustomers = CompanyModule::where('type', BusinessType::IMPORTER)->whereBetween('created_at', [$from, $to])->whereHas('orders', function ($order) {
|
||||||
return $order->whereHas('packingLists');
|
return $order->whereHas('packingLists');
|
||||||
})->count();
|
})->count();
|
||||||
|
|
||||||
@@ -104,8 +114,8 @@ class MonthlyReportController
|
|||||||
'',
|
'',
|
||||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||||
'containers' => count($containers),
|
'containers' => count($containers),
|
||||||
'activated_orders' => count($orders),
|
'activated_orders' => $orders,
|
||||||
'active_customers' => count($customers),
|
'active_customers' => $customers,
|
||||||
'new_customers' => $newCustomers,
|
'new_customers' => $newCustomers,
|
||||||
'new_converted_customers' => $newConvertedCustomers,
|
'new_converted_customers' => $newConvertedCustomers,
|
||||||
'total_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->count(),
|
'total_customers' => CompanyModule::where('type', BusinessType::IMPORTER)->count(),
|
||||||
@@ -117,11 +127,12 @@ class MonthlyReportController
|
|||||||
]]))->handler();
|
]]))->handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function profitModelReport(Request $request): JsonResponse {
|
public function profitModelReport(Request $request): JsonResponse
|
||||||
|
{
|
||||||
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::now()->startOfMonth();
|
||||||
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now()->endOfMonth();
|
||||||
$model = (int) $request->route('model');
|
$model = (int)$request->route('model');
|
||||||
$value = (float) $request->route('value');
|
$value = (float)$request->route('value');
|
||||||
|
|
||||||
$packages = $this->getPackages($from, $to);
|
$packages = $this->getPackages($from, $to);
|
||||||
|
|
||||||
@@ -136,26 +147,26 @@ class MonthlyReportController
|
|||||||
return $packingList->packages;
|
return $packingList->packages;
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
$totalCbm = $packages->sum(function($package){
|
$totalCbm = $packages->sum(function ($package) {
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
});
|
});
|
||||||
|
|
||||||
$projectedCbm = $packages->sum(function($package) use ($value, $model) {
|
$projectedCbm = $packages->sum(function ($package) use ($value, $model) {
|
||||||
|
|
||||||
if($model === 2){
|
if ($model === 2) {
|
||||||
return (( (float) ($package->width + ($package->width * ($value/100))) / 100) * ( (float) ($package->length + ($package->length * ($value/100))) / 100) * ( (float) ($package->height + ($package->height * ($value/100))) / 100)) * $package->quantity;
|
return (((float)($package->width + ($package->width * ($value / 100))) / 100) * ((float)($package->length + ($package->length * ($value / 100))) / 100) * ((float)($package->height + ($package->height * ($value / 100))) / 100)) * $package->quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($model === 3){
|
if ($model === 3) {
|
||||||
return ((( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) + $value) * $package->quantity;
|
return ((((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) + $value) * $package->quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($model === 4){
|
if ($model === 4) {
|
||||||
$packageCbm = (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100));
|
$packageCbm = (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100));
|
||||||
return ( $packageCbm + ($packageCbm * ($value/100))) * $package->quantity;
|
return ($packageCbm + ($packageCbm * ($value / 100))) * $package->quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (( (float) ($package->width + $value) / 100) * ( (float) ($package->length + $value) / 100) * ( (float) ($package->height + $value) / 100)) * $package->quantity;
|
return (((float)($package->width + $value) / 100) * ((float)($package->length + $value) / 100) * ((float)($package->height + $value) / 100)) * $package->quantity;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -167,7 +178,8 @@ class MonthlyReportController
|
|||||||
]]))->handler();
|
]]))->handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerReport(Request $request): JsonResponse {
|
public function customerReport(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
|
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
|
||||||
$id = $connection->invitee->id;
|
$id = $connection->invitee->id;
|
||||||
@@ -190,7 +202,7 @@ class MonthlyReportController
|
|||||||
|
|
||||||
$packages = $this->getPackages($from, $to);
|
$packages = $this->getPackages($from, $to);
|
||||||
|
|
||||||
$packages = $packages->filter(function($package) use ($id) {
|
$packages = $packages->filter(function ($package) use ($id) {
|
||||||
return $package->companyModule->id === $id;
|
return $package->companyModule->id === $id;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -198,8 +210,8 @@ class MonthlyReportController
|
|||||||
return $package->order;
|
return $package->order;
|
||||||
});
|
});
|
||||||
|
|
||||||
$totalCbm = $packages->sum(function($package){
|
$totalCbm = $packages->sum(function ($package) {
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
});
|
});
|
||||||
|
|
||||||
return (new ApiResponseObject('fetch monthly report Successful',
|
return (new ApiResponseObject('fetch monthly report Successful',
|
||||||
@@ -211,32 +223,72 @@ class MonthlyReportController
|
|||||||
]]))->handler();
|
]]))->handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serviceReport(Request $request): JsonResponse {
|
public function serviceReport(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
return (new ApiResponseObject('fetch service report Successful',
|
return (new ApiResponseObject('fetch service report Successful',
|
||||||
'',
|
'',
|
||||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||||
'received' => (float) Package::warehouseReceiveList()->sum('quantity'),
|
'received' => (float)Package::warehouseReceiveList()->sum('quantity'),
|
||||||
'pending_shipment' => (float) Package::shippingList()->whereDoesntHave('shippingSchedules', function($schedule){
|
|
||||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
/* 'pending_shipment' => (float)Package::shippingList()->whereDoesntHave('shippingSchedules', function ($schedule) {
|
||||||
})->sum('quantity'),
|
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||||
'in_transit' => (float) Package::shippingList()->Shipping()->whereHas('shippingSchedules', function($schedule){
|
})->sum('quantity'),
|
||||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
|
||||||
})->whereDoesntHave('container', function($container){
|
'in_transit' => (float) Package::shippingList()->Shipping()->whereHas('shippingSchedules', function($schedule){
|
||||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||||
})->sum('quantity'),
|
})->whereDoesntHave('container', function($container){
|
||||||
'pending_delivery' => (float) Package::shippingList()->whereHas('container', function($container){
|
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
})->sum('quantity'),
|
||||||
})->whereDoesntHave('deliverySchedules', function($schedule){
|
'pending_delivery' => (float) Package::shippingList()->whereHas('container', function($container){
|
||||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||||
})->sum('quantity'),
|
})->whereDoesntHave('deliverySchedules', function($schedule){
|
||||||
'delivered' => (float) Package::shippingList()->whereHas('deliverySchedules', function($schedule){
|
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
})->sum('quantity'),
|
||||||
})->sum('quantity'),
|
'delivered' => (float) Package::shippingList()->whereHas('deliverySchedules', function($schedule){
|
||||||
|
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||||
|
})->sum('quantity'),*/
|
||||||
|
|
||||||
|
'pending_shipment' => (float)Package::shippingList()
|
||||||
|
->whereDoesntHave('shippingSchedules', function ($schedule) {
|
||||||
|
$statuses = [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED];
|
||||||
|
$schedule->dispatched()->whereIn('schedules.status', $statuses);
|
||||||
|
})
|
||||||
|
->sum('quantity'),
|
||||||
|
|
||||||
|
'in_transit' => (float)Package::shippingList()
|
||||||
|
->whereHas('shippingSchedules', function ($schedule) {
|
||||||
|
$statuses = [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED];
|
||||||
|
$schedule->dispatched()->whereIn('schedules.status', $statuses);
|
||||||
|
})
|
||||||
|
->whereDoesntHave('container', function ($container) {
|
||||||
|
$container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||||
|
})
|
||||||
|
->sum('quantity'),
|
||||||
|
|
||||||
|
'pending_delivery' => (float)Package::shippingList()
|
||||||
|
->whereHas('container', function ($container) {
|
||||||
|
$container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||||
|
})
|
||||||
|
->whereDoesntHave('deliverySchedules', function ($schedule) {
|
||||||
|
$statuses = [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED];
|
||||||
|
$schedule->dispatched()->whereIn('schedules.status', $statuses);
|
||||||
|
})
|
||||||
|
->sum('quantity'),
|
||||||
|
|
||||||
|
'delivered' => (float)Package::shippingList()
|
||||||
|
->whereHas('deliverySchedules', function ($schedule) {
|
||||||
|
$statuses = [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED];
|
||||||
|
$schedule->dispatched()->whereIn('schedules.status', $statuses);
|
||||||
|
})
|
||||||
|
->sum('quantity')
|
||||||
|
|
||||||
|
|
||||||
]]))->handler();
|
]]))->handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customerActivityReport(Request $request): JsonResponse {
|
public function customerActivityReport(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
|
||||||
$active_start = $request->input('active_start');
|
$active_start = $request->input('active_start');
|
||||||
$active_end = $request->input('active_end');
|
$active_end = $request->input('active_end');
|
||||||
@@ -255,36 +307,87 @@ class MonthlyReportController
|
|||||||
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
return $query->where('packing_lists.type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('transports', function ($query) use ($active_start, $active_end) {
|
||||||
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
return $query->whereDate('drop_date', '>=', Carbon::parse($active_start))->whereDate('drop_date', '<=', Carbon::parse($active_end)->addDay());
|
||||||
});
|
});
|
||||||
})->whereNotIn('id', $activeCompanies)->get();*/
|
})->whereNotIn('id', $activeCompanies)->get();
|
||||||
|
|
||||||
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||||
|
|
||||||
$customerActivityData = [];
|
$customerActivityData = [];
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
|
|
||||||
foreach ($companies as $key => $company){
|
foreach ($companies as $key => $company) {
|
||||||
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
$connection = $company->inviters()->withPivot('invitee_reference')->first();
|
||||||
$marking = $connection ? $connection->pivot->invitee_reference:'';
|
$marking = $connection ? $connection->pivot->invitee_reference : '';
|
||||||
$packingList = $company->orderPackingLists()->where('packing_lists.type', \App\Classes\ValueObjects\Constants\PackingListType::SHIPPING_PACKING_LIST)->get();
|
$packingList = $company->orderPackingLists()->where('packing_lists.type', PackingListType::SHIPPING_PACKING_LIST)->get();
|
||||||
$totalCbm = $packingList->flatMap(function ($packingList) {
|
$totalCbm = $packingList->flatMap(function ($packingList) {
|
||||||
return $packingList->packages;
|
return $packingList->packages;
|
||||||
})->sum(function($package){
|
})->sum(function ($package) {
|
||||||
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($minCbm != 'null' && $totalCbm < $minCbm) { continue; }
|
if ($minCbm != 'null' && $totalCbm < $minCbm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($minOrders != 'null' && $packingList->count() < $minOrders) { continue; }
|
if ($minOrders != 'null' && $packingList->count() < $minOrders) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
array_push($customerActivityData, array(
|
array_push($customerActivityData, array(
|
||||||
'key' => $counter,
|
'key' => $counter,
|
||||||
'marking' => $marking,
|
'marking' => $marking,
|
||||||
'packingListCount'=> $packingList->count(),
|
'packingListCount' => $packingList->count(),
|
||||||
'totalCbm'=> $totalCbm,
|
'totalCbm' => $totalCbm,
|
||||||
));
|
));
|
||||||
$counter ++;
|
$counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$companies = getActiveCompanies($inactive_start, $inactive_end, $active_start, $active_end);
|
||||||
|
|
||||||
|
$customerActivityData = [];
|
||||||
|
|
||||||
|
$packingListType = PackingListType::SHIPPING_PACKING_LIST;
|
||||||
|
|
||||||
|
$companies->load([
|
||||||
|
'inviters' => function ($query) {
|
||||||
|
$query->withPivot('invitee_reference')->first();
|
||||||
|
},
|
||||||
|
'orderPackingLists' => function ($query) use ($packingListType) {
|
||||||
|
$query->where('packing_lists.type', $packingListType)->with('packages');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
$counter = 1;
|
||||||
|
|
||||||
|
foreach ($companies as $company) {
|
||||||
|
$connection = $company->inviters->first();
|
||||||
|
$marking = $connection ? $connection->pivot->invitee_reference : '';
|
||||||
|
$packingList = $company->orderPackingLists;
|
||||||
|
|
||||||
|
$totalCbm = $packingList->flatMap->packages->sum(function ($package) {
|
||||||
|
return (((float)$package->width / 100) * ((float)$package->length / 100) * ((float)$package->height / 100)) * $package->quantity;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($minCbm !== null && $totalCbm < $minCbm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($minOrders !== null && $packingList->count() < $minOrders) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$customerActivityData[] = [
|
||||||
|
'key' => $counter,
|
||||||
|
'marking' => $marking,
|
||||||
|
'packingListCount' => $packingList->count(),
|
||||||
|
'totalCbm' => $totalCbm,
|
||||||
|
];
|
||||||
|
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (new ApiResponseObject('fetch service report Successful',
|
return (new ApiResponseObject('fetch service report Successful',
|
||||||
'',
|
'',
|
||||||
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
HttpStatus::OK_WITH_MESSAGE, ['data' => [
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Transactions;
|
||||||
|
|
||||||
|
use App\Classes\Modules\Transactions\ControllersLogic\ListMappableTransactionsLogic;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
|
class ListMappableTransactionsController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function list(Request $request, ListMappableTransactionsLogic $logic) : JsonResponse {
|
||||||
|
return $logic->execute($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class AirShipmentItemPriceResource extends JsonResource
|
class AirShipmentItemPriceResource extends JsonResource
|
||||||
@@ -9,10 +10,10 @@ class AirShipmentItemPriceResource extends JsonResource
|
|||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
$object = $this->resource;
|
$object = $this->resource;
|
||||||
$detailsArray = (array)json_decode($object['details']);
|
$detailsArray = (array)json_decode($object['details']);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
@@ -10,10 +11,10 @@ class AnnouncementResource extends JsonResource
|
|||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Resources;
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class BankResource extends JsonResource
|
class BankResource extends JsonResource
|
||||||
@@ -9,10 +10,10 @@ class BankResource extends JsonResource
|
|||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Classes\ValueObjects\Constants\DocumentType;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/*todo delete this*/
|
||||||
class BookingResource extends JsonResource
|
class BookingResource extends JsonResource
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?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 App\Models\Wallet;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MappableTransactionResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$reference = null;
|
||||||
|
if($this->type === TransactionType::TOP_UP) {
|
||||||
|
$reference = $this->owner->owner->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->type === TransactionType::PAYMENT && $this->owner !== Wallet::class){
|
||||||
|
$reference = $this->owner->owner->owner->reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'system' => 'SHIPPING_PORTAL',
|
||||||
|
'type' => $this->type,
|
||||||
|
'owner_type' => $this->owner_type,
|
||||||
|
'owner_id'=> $this->id,
|
||||||
|
'owner_reference'=> $reference,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,9 @@ namespace App\Http\Resources;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
use App\Classes\ValueObjects\Constants\TransportType;
|
||||||
|
use App\Models\Transaction;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
@@ -19,6 +21,8 @@ class OrderResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
$orderId = $this->id;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'reference' => $this->reference,
|
'reference' => $this->reference,
|
||||||
@@ -46,8 +50,8 @@ class OrderResource extends JsonResource
|
|||||||
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
|
'received_packages' => PackingListResource::collection($this->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get()),
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
'invoices' => $this->whenLoaded('packingLists', function() {
|
'invoices' => $this->whenLoaded('packingLists', function() use ($orderId) {
|
||||||
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get());
|
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get());
|
||||||
}),
|
}),
|
||||||
'remarks' => RemarkResource::collection($this->remarks),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'created_at' => $this->created_at->format('d-m-Y')
|
'created_at' => $this->created_at->format('d-m-Y')
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Resources;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\PackingListType;
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use App\Classes\ValueObjects\Constants\TransportType;
|
use App\Classes\ValueObjects\Constants\TransportType;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
@@ -30,7 +31,7 @@ class OrderV2Resource extends JsonResource
|
|||||||
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
'address' => new AddressResource($this->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first()),
|
||||||
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
|
'address_change_request' => new AddressResource($this->addressesPendingVerification()->first()),
|
||||||
'invoices' => $this->whenLoaded('packingLists', function() {
|
'invoices' => $this->whenLoaded('packingLists', function() {
|
||||||
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->get());
|
return TransactionResource::collection($this->transactions()->whereNotIn('transactions.status', [0, 1])->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get());
|
||||||
}),
|
}),
|
||||||
'remarks' => RemarkResource::collection($this->remarks),
|
'remarks' => RemarkResource::collection($this->remarks),
|
||||||
'created_at' => $this->created_at->format('d-m-Y')
|
'created_at' => $this->created_at->format('d-m-Y')
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class TransactionResource extends JsonResource
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
|
'owner_type' => $this->owner_type,
|
||||||
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
|
'order' => ($this->owner instanceof Transaction) ? new OrderResource($this->owner->owner->owner) : new OrderResource($this->owner->owner),
|
||||||
'documents' => DocumentResource::collection($this->documents),
|
'documents' => DocumentResource::collection($this->documents),
|
||||||
'type' => (int) $this->type,
|
'type' => (int) $this->type,
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Library;
|
||||||
|
|
||||||
|
use Spatie\Fractalistic\ArraySerializer;
|
||||||
|
|
||||||
|
class DefaultFractalSerializer extends ArraySerializer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $resourceKey
|
||||||
|
* @param array $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function collection($resourceKey, array $data):array
|
||||||
|
{
|
||||||
|
if ($resourceKey) {
|
||||||
|
return $resourceKey == 'include' ? $data : [$resourceKey => $data];
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $resourceKey
|
||||||
|
* @param array $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function item($resourceKey, array $data):array
|
||||||
|
{
|
||||||
|
if ($resourceKey) {
|
||||||
|
return $resourceKey == 'include' ? $data : [$resourceKey => $data];
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -47,3 +47,38 @@ if (!function_exists('getPackingList')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get Packing List
|
||||||
|
* TODO change all packing related query to this
|
||||||
|
* @param Company $company
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!function_exists('format_number')) {
|
||||||
|
function format_number($number): string
|
||||||
|
{
|
||||||
|
if ($number == 0) {
|
||||||
|
return $number;
|
||||||
|
} elseif (is_float($number)) {
|
||||||
|
return number_format($number, 2);
|
||||||
|
} else {
|
||||||
|
return number_format($number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if a customer have confirmed orders
|
||||||
|
* @param Company $company
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
if (!function_exists('checkIfHasConfirmedOrders'))
|
||||||
|
{
|
||||||
|
function checkIfHasConfirmedOrders(Company $company): bool
|
||||||
|
{
|
||||||
|
return $company->hasConfirmedOrder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
+55
-2
@@ -4,16 +4,22 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Classes\General\Interfaces\Contactable;
|
use App\Classes\General\Interfaces\Contactable;
|
||||||
use App\Classes\General\Interfaces\Remarkable;
|
use App\Classes\General\Interfaces\Remarkable;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
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\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Address
|
* Class Address
|
||||||
* @package App\Models
|
|
||||||
*
|
*
|
||||||
|
* @package App\Models
|
||||||
* @property int country_id
|
* @property int country_id
|
||||||
* @property int company_id
|
* @property int company_id
|
||||||
* @property int state_id
|
* @property int state_id
|
||||||
@@ -22,6 +28,53 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|||||||
* @property string street_one
|
* @property string street_one
|
||||||
* @property string street_two
|
* @property string street_two
|
||||||
* @property integer billing_type
|
* @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
|
class Address extends AbstractModel implements Contactable, Remarkable
|
||||||
{
|
{
|
||||||
@@ -58,7 +111,7 @@ class Address extends AbstractModel implements Contactable, Remarkable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
* @return MorphTo
|
||||||
*/
|
*/
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,56 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
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\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Announcement
|
* Class Announcement
|
||||||
* @package App\Models
|
|
||||||
*
|
*
|
||||||
|
* @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
|
class Announcement extends AbstractModel
|
||||||
{
|
{
|
||||||
@@ -17,7 +60,7 @@ class Announcement extends AbstractModel
|
|||||||
protected $table = 'announcements';
|
protected $table = 'announcements';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
* @return BelongsToMany
|
||||||
**/
|
**/
|
||||||
public function segments(): BelongsToMany
|
public function segments(): BelongsToMany
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,13 +3,64 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
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\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
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
|
class BankAccount extends AbstractModel implements DataTransferObject
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|||||||
+22
-2
@@ -111,12 +111,32 @@ class Company extends AbstractModel implements Documentable, Contactable
|
|||||||
$orders = [];
|
$orders = [];
|
||||||
|
|
||||||
$this->CompanyModules->each(function ($companyModule) {
|
$this->CompanyModules->each(function ($companyModule) {
|
||||||
$orders[] = $companyModule->orders->sortByDesc('id');
|
$orders[] = $companyModule->orders->sortByDesc('id');
|
||||||
});
|
});
|
||||||
|
|
||||||
return collect($orders);
|
return collect($orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has Confirmed orders
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasConfirmedOrder(): bool
|
||||||
|
{
|
||||||
|
$importerModule = $this->companyModules()->where('type', BusinessType::IMPORTER)->first();
|
||||||
|
|
||||||
|
if (!$importerModule) {
|
||||||
|
return false; // Return false if no relation found
|
||||||
|
}
|
||||||
|
|
||||||
|
$hasConfirmedOrder = $importerModule->orders()
|
||||||
|
->where('status', '!=', 0)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
return (bool)$hasConfirmedOrder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return MorphMany
|
* @return MorphMany
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ use App\Classes\General\Interfaces\Packable;
|
|||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||||
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@@ -20,18 +22,83 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use PhpParser\Node\Expr\AssignOp\Mod;
|
use PhpParser\Node\Expr\AssignOp\Mod;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
use App\Classes\General\Interfaces\Remarkable;
|
use App\Classes\General\Interfaces\Remarkable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CompanyModule
|
* Class CompanyModule
|
||||||
* @package App\Models
|
|
||||||
*
|
*
|
||||||
* @property \App\Models\Company company_id
|
* @package App\Models
|
||||||
|
* @property Company company_id
|
||||||
* @property integer type
|
* @property integer type
|
||||||
* @property integer status
|
* @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
|
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner, Packable, Remarkable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,12 +5,63 @@ namespace App\Models;
|
|||||||
use App\Classes\General\Interfaces\Remarkable;
|
use App\Classes\General\Interfaces\Remarkable;
|
||||||
use App\Classes\General\Interfaces\Transportable;
|
use App\Classes\General\Interfaces\Transportable;
|
||||||
use App\Classes\General\Traits\LogData;
|
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\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
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
|
class Container extends AbstractModel implements Transportable, Remarkable
|
||||||
{
|
{
|
||||||
use HasRelationships;
|
use HasRelationships;
|
||||||
|
|||||||
+34
-2
@@ -2,20 +2,52 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
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\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\hasMany;
|
use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Currency
|
* Class Currency
|
||||||
* @package App\Models
|
|
||||||
*
|
*
|
||||||
* @property \App\Models\Country country_id
|
* @package App\Models
|
||||||
|
* @property Country country_id
|
||||||
* @property string name
|
* @property string name
|
||||||
* @property string short_code
|
* @property string short_code
|
||||||
* @property string symbol
|
* @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
|
class Currency extends AbstractModel
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use Spatie\Activitylog\Models\Activity;
|
|||||||
* @property int document_type
|
* @property int document_type
|
||||||
* @property string reference
|
* @property string reference
|
||||||
* @property int status
|
* @property int status
|
||||||
* @property \App\Models\User approver
|
* @property User approver
|
||||||
* @property timestamp issued_date
|
* @property timestamp issued_date
|
||||||
* @property timestamp expired_date
|
* @property timestamp expired_date
|
||||||
* @property timestamp approved_date
|
* @property timestamp approved_date
|
||||||
@@ -70,7 +70,7 @@ class Document extends AbstractModel
|
|||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
* @return MorphTo
|
||||||
*/
|
*/
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Classes\General\Traits\LogData;
|
use App\Classes\General\Traits\LogData;
|
||||||
|
use Eloquent;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Classes\General\Interfaces\Documentable;
|
use App\Classes\General\Interfaces\Documentable;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@@ -10,13 +13,32 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
use App\Classes\General\Interfaces\Transactionable;
|
use App\Classes\General\Interfaces\Transactionable;
|
||||||
|
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
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
|
class Group extends Model implements Documentable, Transactionable
|
||||||
{
|
{
|
||||||
use HasRelationships;
|
use HasRelationships;
|
||||||
|
use HasTableAlias;
|
||||||
|
|
||||||
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,69 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
|||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Scopes\CustomerOrdersScope;
|
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\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
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\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* App\Models\Order
|
||||||
|
*
|
||||||
* @method static whereBetween(string $string, array $array)
|
* @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
|
class Order extends AbstractModel implements Addressable, Packable, Remarkable, Notifiable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,15 +7,71 @@ use App\Classes\ValueObjects\Constants\PackingListType;
|
|||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
use App\Scopes\CustomerOrdersScope;
|
use App\Scopes\CustomerOrdersScope;
|
||||||
use App\Scopes\CustomerPackagesScope;
|
use App\Scopes\CustomerPackagesScope;
|
||||||
|
use Barryvdh\LaravelIdeHelper\Eloquent;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Query\Builder;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasOneDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasOneDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
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
|
class Package extends AbstractModel
|
||||||
{
|
{
|
||||||
use HasRelationships;
|
use HasRelationships;
|
||||||
|
|||||||
@@ -10,15 +10,78 @@ use App\Classes\General\Interfaces\Transactionable;
|
|||||||
use App\Classes\General\Traits\LogData;
|
use App\Classes\General\Traits\LogData;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use Carbon\Carbon;
|
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\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Query\Builder;
|
||||||
|
use Spatie\Activitylog\Models\Activity;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||||
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
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
|
class PackingList extends AbstractModel implements Transportable, Steppable, Packable, Transactionable
|
||||||
{
|
{
|
||||||
use HasTableAlias;
|
use HasTableAlias;
|
||||||
@@ -31,7 +94,7 @@ class PackingList extends AbstractModel implements Transportable, Steppable, Pac
|
|||||||
protected $fillable = ['status'];
|
protected $fillable = ['status'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
* @return MorphTo
|
||||||
*/
|
*/
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,10 +2,50 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
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\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
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
|
class Remark extends AbstractModel
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|||||||
@@ -4,10 +4,51 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use Carbon\Carbon;
|
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\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
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
|
class Schedule extends AbstractModel
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|||||||
@@ -9,19 +9,104 @@ use App\Classes\General\Traits\LogData;
|
|||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Eloquent;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
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\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
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
|
class Transaction extends AbstractModel implements Documentable, Transactionable, Remarkable
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use LogData;
|
use LogData;
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'type' => 'int'
|
||||||
|
];
|
||||||
|
|
||||||
protected $table = 'transactions';
|
protected $table = 'transactions';
|
||||||
|
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
|
|||||||
@@ -2,9 +2,49 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
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\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
|
class TransactionDetail extends AbstractModel
|
||||||
{
|
{
|
||||||
protected $table = 'transaction_details';
|
protected $table = 'transaction_details';
|
||||||
|
|||||||
@@ -4,10 +4,59 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use Carbon\Carbon;
|
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\Relations\MorphTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
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
|
class Transport extends AbstractModel
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
@@ -19,7 +68,7 @@ class Transport extends AbstractModel
|
|||||||
protected $dates = ['dispatch_date', 'drop_date'];
|
protected $dates = ['dispatch_date', 'drop_date'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
* @return MorphTo
|
||||||
*/
|
*/
|
||||||
public function owner(): morphTo
|
public function owner(): morphTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<?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 array $defaultIncludes = [
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'company_module',
|
||||||
|
'Owner_address',
|
||||||
|
'remark',
|
||||||
|
'contact',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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()),
|
||||||
|
])
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?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'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
<?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 array $defaultIncludes = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'company',
|
||||||
|
'remarks',
|
||||||
|
'contact',
|
||||||
|
'address',
|
||||||
|
'billingAddress',
|
||||||
|
'connections',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
'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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include connections
|
||||||
|
* @param CompanyModule $module
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeConnections(CompanyModule $module): Item
|
||||||
|
{
|
||||||
|
$connection = $module->connections;
|
||||||
|
return $this->item($connection, new ConnectionTransformer());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Models\CompanyModule;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
@@ -15,7 +16,7 @@ class CompanyTransformer extends TransformerAbstract
|
|||||||
* List of all default includes
|
* List of all default includes
|
||||||
*/
|
*/
|
||||||
protected array $defaultIncludes = [
|
protected array $defaultIncludes = [
|
||||||
'contact',
|
'company_module'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,15 +26,14 @@ class CompanyTransformer extends TransformerAbstract
|
|||||||
protected array $availableIncludes = [
|
protected array $availableIncludes = [
|
||||||
|
|
||||||
'segments',
|
'segments',
|
||||||
'employee',
|
|
||||||
'company_module',
|
|
||||||
'last_order',
|
'last_order',
|
||||||
'order_count',
|
|
||||||
'identification',
|
'identification',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function transform(Company $company): array
|
public function transform(Company $company): array
|
||||||
{
|
{
|
||||||
|
$companyModule = $company->companyModules()->first();
|
||||||
|
$hasConfirmedOrders = checkIfHasConfirmedOrders($company);
|
||||||
return [
|
return [
|
||||||
'id' => $company->id,
|
'id' => $company->id,
|
||||||
'hash_id' => Crypt::encryptString($company->id),
|
'hash_id' => Crypt::encryptString($company->id),
|
||||||
@@ -43,7 +43,9 @@ class CompanyTransformer extends TransformerAbstract
|
|||||||
'type' => $company->type,
|
'type' => $company->type,
|
||||||
'business_type' => (int)$company->business_type,
|
'business_type' => (int)$company->business_type,
|
||||||
'status' => $company->status,
|
'status' => $company->status,
|
||||||
'created_at' => $company->created_at->format('d-m-Y')
|
'created_at' => $company->created_at->format('d-m-Y'),
|
||||||
|
'order_count' => $companyModule->orders()->count(),
|
||||||
|
'has_confirmed_order' => $hasConfirmedOrders,
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,6 +54,7 @@ class CompanyTransformer extends TransformerAbstract
|
|||||||
/**
|
/**
|
||||||
* Include Contact
|
* Include Contact
|
||||||
*
|
*
|
||||||
|
* @param Company $company
|
||||||
* @return Item
|
* @return Item
|
||||||
*/
|
*/
|
||||||
public function includeContact(Company $company): Item
|
public function includeContact(Company $company): Item
|
||||||
@@ -60,4 +63,30 @@ class CompanyTransformer extends TransformerAbstract
|
|||||||
|
|
||||||
return $this->item($contact->first(), new ContactTransformer());
|
return $this->item($contact->first(), new ContactTransformer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add Employee to owner
|
||||||
|
* @param Company $company
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeEmployee(Company $company): Item
|
||||||
|
{
|
||||||
|
$companyModule = $company->companyModules()->first();
|
||||||
|
|
||||||
|
$employee = $companyModule->employees()->first();
|
||||||
|
|
||||||
|
return $this->item($employee, new UserTransformer());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include a company Module to the Owner Object
|
||||||
|
* @param Company $company
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeCompanyModule(Company $company): Item
|
||||||
|
{
|
||||||
|
$companyModule = $company->companyModules()->first();
|
||||||
|
return $this->item($companyModule, new CompanyModuleTransformer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class ConnectionTransformer 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.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\AddressType;
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Models\Order;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class DeliveryOrderTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultIncludes = [
|
||||||
|
'company_module',
|
||||||
|
'sender_address',
|
||||||
|
'delivery_address',
|
||||||
|
'packingList',
|
||||||
|
'remarks'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $availableIncludes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @param Order $order
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Order $order): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $order->id,
|
||||||
|
'reference' => $order->reference,
|
||||||
|
'type' => $order->type,
|
||||||
|
'status' => $order->status,
|
||||||
|
'created_at' => $order->created_at->format('d-m-Y')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include CompanyModule
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeCompanyModule(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->companyModule, new CompanyModuleTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include SenderAddress
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeSenderAddress(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::PICK_UP)->first(), new AddressTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include DeliveryAddress
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function includeDeliveryAddress(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->addresses()->where('status', '=', ApprovalStatus::APPROVED)->where('type', AddressType::DELIVERY)->first(), new AddressTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include PackingList
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includePackingList(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->packingLists()->first(), new DeliveryPackingListTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Remarks
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeRemarks(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->remarks, new RemarkTransformer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class DeliveryPackingListTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultIncludes = [
|
||||||
|
'transport'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $availableIncludes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(PackingList $list): array
|
||||||
|
{
|
||||||
|
$package = $list->packages()->first();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $list->id,
|
||||||
|
'claimant_id' => $list->claimant_id,
|
||||||
|
'reference' => $list->reference,
|
||||||
|
'status' => $list->status,
|
||||||
|
'type' => $package->type,
|
||||||
|
'description' => $package->description,
|
||||||
|
'weight' => (float)$package->weight,
|
||||||
|
'quantity' => (float)$package->quantity,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Transport
|
||||||
|
*
|
||||||
|
* @param PackingList $list
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeTransport(PackingList $list): Item
|
||||||
|
{
|
||||||
|
return $this->item($list->transports()->first(), new TransportTransformer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,10 @@ namespace App\Transformers;
|
|||||||
|
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use League\Fractal\Manager;
|
||||||
use League\Fractal\Resource\Collection;
|
use League\Fractal\Resource\Collection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
use League\Fractal\TransformerAbstract;
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
class DocumentTransformer extends TransformerAbstract
|
class DocumentTransformer extends TransformerAbstract
|
||||||
@@ -40,13 +42,22 @@ class DocumentTransformer extends TransformerAbstract
|
|||||||
public function includeFiles(Document $document): Collection
|
public function includeFiles(Document $document): Collection
|
||||||
{
|
{
|
||||||
$files = $document->files;
|
$files = $document->files;
|
||||||
return $this->collection($files, new FileTransformer());
|
return $this->collection($files, new FileTransformer(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include owner data
|
||||||
|
* @param Document $document
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
public function includeOwner(Document $document): Item
|
public function includeOwner(Document $document): Item
|
||||||
{
|
{
|
||||||
$owner = $document->owner;
|
$owner = $document->owner;
|
||||||
return $this->item($owner, new CompanyTransformer());
|
|
||||||
|
$transformer = new CompanyTransformer();
|
||||||
|
$transformer->setDefaultIncludes([ 'contact', 'employee', 'company_module']);
|
||||||
|
|
||||||
|
return $this->item($owner, $transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ use League\Fractal\TransformerAbstract;
|
|||||||
class FileTransformer extends TransformerAbstract
|
class FileTransformer extends TransformerAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool|mixed|null
|
||||||
|
*/
|
||||||
|
private bool $loadMediumAndOriginal;
|
||||||
|
|
||||||
|
public function __construct($loadMediumAndOriginal = false)
|
||||||
|
{
|
||||||
|
$this->loadMediumAndOriginal = $loadMediumAndOriginal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AA Array of possible includes for file model
|
* AA Array of possible includes for file model
|
||||||
* @var array
|
* @var array
|
||||||
@@ -23,10 +34,23 @@ class FileTransformer extends TransformerAbstract
|
|||||||
*/
|
*/
|
||||||
public function transform(File $file): array
|
public function transform(File $file): array
|
||||||
{
|
{
|
||||||
|
if ($this->loadMediumAndOriginal) {
|
||||||
|
$files = $file->file;
|
||||||
|
$newObject = $files->file_info = collect($files->file_info)
|
||||||
|
->filter(function ($file) {
|
||||||
|
return !isset($file->large) && !isset($file->small);
|
||||||
|
})
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$newObject = $file->file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $file->id,
|
'id' => $file->id,
|
||||||
'file' => $file->file,
|
'file' => $newObject,
|
||||||
'type' => (int)$file->file_type,
|
'type' => (int)$file->file_type,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class GroupTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultIncludes = [
|
||||||
|
'original_currency',
|
||||||
|
'currency',
|
||||||
|
'documents'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $availableIncludes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Transaction $transaction): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $transaction->id,
|
||||||
|
'original_amount' => (float)$transaction->original_amount,
|
||||||
|
'issuer_name' => $transaction->issuerCompany->name,
|
||||||
|
'issuer_id' => $transaction->issuerCompany->id,
|
||||||
|
'amount' => (float)$transaction->amount,
|
||||||
|
'service_charge' => (float)$transaction->amount,
|
||||||
|
'created_at' => Carbon::parse($transaction->created_at)->format('d-m-Y h:i:s A'),
|
||||||
|
'currency_rate' => (float)$transaction->currency_rate,
|
||||||
|
'transactions' => $this->transactions($transaction),
|
||||||
|
'complete_transactions' => $this->complete_transactions($transaction),
|
||||||
|
'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())
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Original Currency
|
||||||
|
*
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeOriginalCurrency(Transaction $transaction): Item
|
||||||
|
{
|
||||||
|
return $this->item($transaction->original_currency, new CurrencyTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Currency
|
||||||
|
*
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeCurrency(Transaction $transaction): Item
|
||||||
|
{
|
||||||
|
return $this->item($transaction->currency, new CurrencyTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Transactions
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
protected function transactions(Transaction $transaction): Collection
|
||||||
|
{
|
||||||
|
return $transaction->transactions()->get()->pluck('owner.owner.marking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* complete Transactions
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
protected function complete_transactions(Transaction $transaction): Collection
|
||||||
|
{
|
||||||
|
return $transaction->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');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Documents
|
||||||
|
*
|
||||||
|
* @param Transaction $transaction
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function includeDocuments(Transaction $transaction): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'currency_order' => $this->item($transaction->documents()->where('document_type', DocumentType::CURRENCY_VENDOR_ORDER)->first(), new DocumentTransformer()),
|
||||||
|
'purchase_order' => $this->item($transaction->documents()->where('document_type', DocumentType::BULK_PURCHASE_ORDER)->first(), new DocumentTransformer())
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class InvoiceTransformer 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.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
||||||
|
use App\Classes\ValueObjects\Constants\PackingListType;
|
||||||
|
use App\Models\Order;
|
||||||
|
use League\Fractal\Resource\Collection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class OrderTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $defaultIncludes = [
|
||||||
|
'company_module',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'parcels',
|
||||||
|
'invoices',
|
||||||
|
'warehouse',
|
||||||
|
'address',
|
||||||
|
'address_change_request',
|
||||||
|
'remarks'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @param Order $order
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Order $order): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $order->id,
|
||||||
|
'reference' => $order->reference,
|
||||||
|
'reference_contract' => $order->type,
|
||||||
|
'type' => $order->type,
|
||||||
|
'status' => $order->status,
|
||||||
|
'created_at' => $order->created_at->format('d-m-Y')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include company module
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeCompanyModule(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->companyModule, new CompanyModuleTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Include warehouse
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeWarehouse(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->orderRoles()->where('role_id', '=', OrderRoleTypes::ORIGIN_WAREHOUSE)->first()->appointee, new CompanyModuleTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include address
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeAddress(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->addresses()->where('status', '=', ApprovalStatus::APPROVED)->first(), new AddressTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include address change request
|
||||||
|
* @param Order $order
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeAddressChangeRequest(Order $order): Item
|
||||||
|
{
|
||||||
|
return $this->item($order->addressesPendingVerification()->first(), new AddressTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include parcels
|
||||||
|
* @param Order $order
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function includeParcels(Order $order): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'origin_warehouse_packages' => $this->collection($order->originWarehousePackages()->get(), new PackageListTransformer()),
|
||||||
|
|
||||||
|
'in_transit_packages' => $this->collection($order->inTransitPackages()->get(), new PackageListTransformer()),
|
||||||
|
|
||||||
|
'destination_warehouse_packages' => $this->collection($order->destinationWarehousePackages()->get(), new PackageListTransformer()),
|
||||||
|
|
||||||
|
'delivered_packages' => $this->collection($order->deliveredPackages()->get(), new PackageListTransformer()),
|
||||||
|
|
||||||
|
'received_packages' => $this->collection($order->packingLists()->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->whereHas('packages')->get(), new PackageListTransformer()),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* include invoices
|
||||||
|
* @param Order $order
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function includeInvoices(Order $order): Collection
|
||||||
|
{
|
||||||
|
|
||||||
|
$invoices = $order->transactions()->whereNotIn('transactions.status', [0, 1])->get();
|
||||||
|
return $this->collection($invoices, new TransactionTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function includeRemarks(Order $order): Collection
|
||||||
|
{
|
||||||
|
return $this->collection($order->remarks()->get(), new RemarkTransformer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||||
|
use App\Models\PackingList;
|
||||||
|
use League\Fractal\Resource\Collection;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class PackageListTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $defaultIncludes = [
|
||||||
|
'transport',
|
||||||
|
'packages',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
'order',
|
||||||
|
'receive_packing_list',
|
||||||
|
'shipping_transaction',
|
||||||
|
'suspended_invoice'
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(PackingList $packingList): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $packingList->id,
|
||||||
|
'claimant_id' => $packingList->claimant_id,
|
||||||
|
'reference' => $packingList->reference,
|
||||||
|
'status' => $packingList->status,
|
||||||
|
'type' => $packingList->type,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include Transport
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeTransport(PackingList $packingList): Item
|
||||||
|
{
|
||||||
|
return $this->item($packingList->transport()->first(), new TransportTransformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Receive Packing List
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeReceivePackageList(PackingList $packingList): Item
|
||||||
|
{
|
||||||
|
|
||||||
|
//$this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())),
|
||||||
|
|
||||||
|
return $this->item($packingList->receivePackageList()->first(), new PackageListTransformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Packages
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function includePackages(PackingList $packingList): Collection
|
||||||
|
{
|
||||||
|
$exceptionUsers = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
|
||||||
|
$packages = !$packingList->packingLists()->exists() || $exceptionUsers ? $packingList->packages : $packingList->packingLists->first()->packages;
|
||||||
|
|
||||||
|
return $this->collection($packages, new PackageTransformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include Order
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeOrder(PackingList $packingList): Item
|
||||||
|
{
|
||||||
|
return $this->item($packingList->owner, new OrderTransformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include Shipping Transaction
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeShippingTransaction(PackingList $packingList): Item
|
||||||
|
{
|
||||||
|
return $this->item($packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first(), new TransactionTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* include Suspended Invoice
|
||||||
|
* @param PackingList $packingList
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeSuspendedInvoice(PackingList $packingList): Item
|
||||||
|
{
|
||||||
|
return $this->item($packingList->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first(), new TransactionTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Package;
|
||||||
|
use League\Fractal\Resource\Item;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class PackageTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $defaultIncludes = [
|
||||||
|
'transport',
|
||||||
|
'container'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $availableIncludes = [
|
||||||
|
'order'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @param Package $package
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Package $package): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $package->id,
|
||||||
|
'type' => $package->type,
|
||||||
|
'description' => $package->description,
|
||||||
|
'width' => floatval($package->width),
|
||||||
|
'height' => floatval($package->height),
|
||||||
|
'length' => floatval($package->length),
|
||||||
|
'weight' => $package->weight,
|
||||||
|
'quantity' => $package->quantity,
|
||||||
|
'cbm' => (($package->width / 100) * ($package->height / 100) * ($package->length / 100)) * $package->quantity,
|
||||||
|
'reference' => $package->packingList->reference,
|
||||||
|
'status' => $package->status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Transport
|
||||||
|
* @param Package $package
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeTransport(Package $package): Item
|
||||||
|
{
|
||||||
|
return $this->item($package->packingList->transports()->first(), new TransportTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Container
|
||||||
|
* @param Package $package
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeContainers(Package $package): Item
|
||||||
|
{
|
||||||
|
return $this->item($package->packingList->containers()->first(), new TransportTransformer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include Order
|
||||||
|
* @param Package $package
|
||||||
|
* @return Item
|
||||||
|
*/
|
||||||
|
public function includeOrder(Package $package): Item
|
||||||
|
{
|
||||||
|
return $this->item($package->packingList->owner, new OrderTransformer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Http\Resources\UserResource;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Remark;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class RemarkTransformer extends TransformerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List of resources to automatically include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $defaultIncludes = [
|
||||||
|
'commenter'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of resources possible to include
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected array $availableIncludes = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Fractal transformer.
|
||||||
|
*
|
||||||
|
* @param Remark $remark
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Remark $remark): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $remark->id,
|
||||||
|
'owner_id' => $remark->owner_id,
|
||||||
|
'content' => $remark->content,
|
||||||
|
'created_at' => $remark->created_at->format('d-m-Y H:i'),
|
||||||
|
'long_ago' => $remark->created_at->diffForHumans()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load commenter
|
||||||
|
* @param Remark $remark
|
||||||
|
* @return \League\Fractal\Resource\Item
|
||||||
|
*/
|
||||||
|
public function includeCommenter(Remark $remark): \League\Fractal\Resource\Item
|
||||||
|
{
|
||||||
|
$user = $remark->commenter();
|
||||||
|
return $this->item($user, new UserTransformer());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Schedule;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use League\Fractal\TransformerAbstract;
|
||||||
|
|
||||||
|
class ScheduleTransformer 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 Schedule $schedule
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function transform(Schedule $schedule): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $schedule->id,
|
||||||
|
'etd' => $schedule->etd ? $schedule->etd->format('d-m-Y') : 'n/a',
|
||||||
|
'eta' => $schedule->eta ? $schedule->eta->format('d-m-Y') : 'n/a',
|
||||||
|
'billing_days_left' => [
|
||||||
|
'value' => (Carbon::parse($schedule->eta)->subDays(7)->gt(Carbon::now())) ? '+' : '-',
|
||||||
|
'duration' => Carbon::parse($schedule->eta)->subDays(7)->diffInDays(Carbon::now()),
|
||||||
|
],
|
||||||
|
'status' => $schedule->status,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user