mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Update: laravel 8 to 12, php 7.3 to php 8.3, Jenkinsfile, Unit/Feature testing, vapor
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=testing
|
||||
|
||||
APP_KEY=base64:I9qXyDlm7GVu/e47+YGzLB00fA/FMA2/hMPEhqu8pUQ=
|
||||
JWT_SECRET=9j7f7vUWEzxUBjLYcQimZp5wmxHEglcjU3beog26qC4pQKENZSpfWQfv065tjZrZ
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=172.18.0.3
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=ci_test_shipping_portal
|
||||
DB_USERNAME=ci
|
||||
DB_PASSWORD=bi9y@T8r
|
||||
@@ -6,6 +6,7 @@
|
||||
**/.idea/
|
||||
.env
|
||||
.env.backup
|
||||
.env.testing.example
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
@@ -29,3 +30,5 @@ storage/framework/laravel-excel/*
|
||||
.env.production
|
||||
.env.staging
|
||||
.env.development
|
||||
docz/*
|
||||
.phpunit.cache/
|
||||
|
||||
Vendored
+47
-16
@@ -9,17 +9,17 @@
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
args '--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock'
|
||||
image '303644228504.dkr.ecr.ap-southeast-1.amazonaws.com/jenkins-pipeline-agent:latest'
|
||||
args '--network ci-net --group-add 992 -v /var/run/docker.sock:/var/run/docker.sock'
|
||||
image '303644228504.dkr.ecr.ap-southeast-1.amazonaws.com/jenkins-pipeline-agent-php-8.3:latest'
|
||||
registryCredentialsId "ecr:ap-southeast-1:aws-ec2-instance-iam-role"
|
||||
registryUrl "https://303644228504.dkr.ecr.ap-southeast-1.amazonaws.com"
|
||||
}
|
||||
}
|
||||
environment {
|
||||
HOME = '.'
|
||||
DB_CONNECTION = 'mysql'
|
||||
DB_DATABASE = 'portal_development'
|
||||
APP_ENV = 'testing'
|
||||
// DB_CONNECTION = 'mysql'
|
||||
// DB_DATABASE = 'portal_development'
|
||||
// APP_ENV = 'testing'
|
||||
}
|
||||
stages {
|
||||
stage('Download source code from Git') {
|
||||
@@ -31,6 +31,7 @@ pipeline {
|
||||
case "vapor/production":
|
||||
case "vapor/staging":
|
||||
case "vapor/development":
|
||||
case "vapor/test":
|
||||
git(
|
||||
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git',
|
||||
credentialsId: 'gitlab-jenkins-localhost',
|
||||
@@ -61,18 +62,45 @@ pipeline {
|
||||
|
||||
stage('Tests') {
|
||||
steps {
|
||||
//sh 'vendor/bin/phpunit tests/Unit'
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: 'shipping-portal-dev-db-credential',
|
||||
usernameVariable: 'DB_USERNAME',
|
||||
passwordVariable: 'DB_PASSWORD'
|
||||
),
|
||||
string(credentialsId: 'shipping-portal-dev-db-host', variable: 'DB_HOST')
|
||||
]) {
|
||||
// sh 'vendor/bin/phpunit tests/Unit'
|
||||
// withCredentials([
|
||||
// usernamePassword(
|
||||
// credentialsId: 'shipping-portal-dev-db-credential',
|
||||
// usernameVariable: 'DB_USERNAME',
|
||||
// passwordVariable: 'DB_PASSWORD'
|
||||
// ),
|
||||
// string(credentialsId: 'shipping-portal-dev-db-host', variable: 'DB_HOST')
|
||||
// ]) {
|
||||
// sh 'vendor/bin/phpunit --filter ListOrderTrackingLogicTest'
|
||||
}
|
||||
script{
|
||||
// }
|
||||
sh '''
|
||||
set -e
|
||||
|
||||
export APP_ENV=testing
|
||||
# export APP_KEY=$(php -r "echo 'base64:'.base64_encode(random_bytes(32));")
|
||||
# export JWT_SECRET=$(php -r "echo bin2hex(random_bytes(32));")
|
||||
|
||||
# Show which PHP binary is used
|
||||
which php
|
||||
php -v
|
||||
|
||||
# List PHP modules to confirm pdo_mysql
|
||||
php -m | grep pdo_mysql || echo "pdo_mysql not loaded"
|
||||
|
||||
# Show DB environment variables
|
||||
echo "DB_CONNECTION=$DB_CONNECTION"
|
||||
echo "DB_HOST=$DB_HOST"
|
||||
echo "DB_PORT=$DB_PORT"
|
||||
echo "DB_DATABASE=$DB_DATABASE"
|
||||
echo "DB_USERNAME=$DB_USERNAME"
|
||||
# Do NOT echo password in logs
|
||||
|
||||
php artisan migrate:fresh --force
|
||||
|
||||
vendor/bin/phpunit -c phpunit.ci.xml --group ok_to_run
|
||||
|
||||
'''
|
||||
script {
|
||||
currentBuild.description = 'Step 4 of 6 Completed'
|
||||
}
|
||||
}
|
||||
@@ -94,6 +122,9 @@ pipeline {
|
||||
case "vapor/development":
|
||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
||||
break
|
||||
case "vapor/test":
|
||||
sh "vendor/bin/vapor deploy test --message='${gitCommitMessage}'"
|
||||
break
|
||||
case "origin/dillon/34-jenkins-vapor":
|
||||
sh "vendor/bin/vapor deploy development --message='${gitCommitMessage}'"
|
||||
break
|
||||
|
||||
@@ -19,22 +19,29 @@ abstract class AbstractGetRecord
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
private function getQueryFilters(){
|
||||
private function getQueryFilters()
|
||||
{
|
||||
return $this->filters->except(self::DECORATION_FILTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getDecorationFilters(){
|
||||
public function getDecorationFilters()
|
||||
{
|
||||
return $this->filters->only(self::DECORATION_FILTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null|string $json
|
||||
* @param null|string|array $json
|
||||
* @return array
|
||||
*/
|
||||
public function deserializeFilters(?string $json): array {
|
||||
public function deserializeFilters($json): array
|
||||
{
|
||||
if (is_array($json)) {
|
||||
return $json;
|
||||
}
|
||||
|
||||
return $json !== null ? collect(json_decode($json))->toArray() : [];
|
||||
}
|
||||
|
||||
@@ -50,7 +57,8 @@ abstract class AbstractGetRecord
|
||||
* @param array $filters
|
||||
* @return mixed
|
||||
*/
|
||||
public function handler(array $filters, array $params = []){
|
||||
public function handler(array $filters, array $params = [])
|
||||
{
|
||||
$this->filters = collect($filters);
|
||||
return $this->getResults($this->applyFiltersToQuery(), $params);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\JWT;
|
||||
|
||||
class GeneratesAuthenticationToken {
|
||||
class GeneratesAuthenticationToken
|
||||
{
|
||||
|
||||
/** @var JWT */
|
||||
private $builder;
|
||||
@@ -21,7 +22,8 @@ class GeneratesAuthenticationToken {
|
||||
* GeneratesAuthenticationToken constructor.
|
||||
* @param JWT $builder
|
||||
*/
|
||||
public function __construct(JWT $builder) {
|
||||
public function __construct(JWT $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
@@ -31,15 +33,16 @@ class GeneratesAuthenticationToken {
|
||||
* @param bool $rememberUser
|
||||
* @return string
|
||||
*/
|
||||
public function execute(User $user, bool $rememberUser = false): string {
|
||||
public function execute(User $user, bool $rememberUser = false): string
|
||||
{
|
||||
|
||||
$this->builder->manager()->setBlacklistEnabled(false);
|
||||
|
||||
// generate token for the customer
|
||||
$this->builder->factory()->setTTL(Carbon::now()->addDay()->timestamp);
|
||||
$this->builder->factory()->setTTL(525600); // 1 year
|
||||
|
||||
if ($rememberUser === true) {
|
||||
$this->builder->factory()->setTTL(Carbon::now()->addWeek()->timestamp);
|
||||
$this->builder->factory()->setTTL(525600); // 1 year
|
||||
}
|
||||
|
||||
// set the claim based on the object
|
||||
@@ -52,7 +55,8 @@ class GeneratesAuthenticationToken {
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
private function setTokenClaims(User $user): void {
|
||||
private function setTokenClaims(User $user): void
|
||||
{
|
||||
|
||||
$claims = [
|
||||
'id' => $user->id,
|
||||
@@ -62,7 +66,7 @@ class GeneratesAuthenticationToken {
|
||||
'status' => $user->status
|
||||
];
|
||||
|
||||
if($user->type === RoleTypes::USER) {
|
||||
if ($user->type === RoleTypes::USER) {
|
||||
|
||||
/** @var Company $companyModule */
|
||||
$companyModule = $user->companyModule()->first();
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UserCreateValidation extends AbstractValidation
|
||||
{
|
||||
@@ -29,7 +30,7 @@ class UserCreateValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|unique:users',
|
||||
'email' => ['required', Rule::unique('users')],
|
||||
'password' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Accounts\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UserRegistrationValidation extends AbstractValidation
|
||||
{
|
||||
@@ -32,7 +33,7 @@ class UserRegistrationValidation extends AbstractValidation
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|max:255|unique:users,email',
|
||||
'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')],
|
||||
'password' => 'required|min:6|confirmed',
|
||||
'type' => 'required',
|
||||
'status' => 'required'
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
use App\Classes\ValueObjects\Constants\FileType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class FileObject implements DataTransferObject
|
||||
{
|
||||
@@ -28,7 +30,13 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data);
|
||||
// intervention/image v2: old
|
||||
// return in_array($this->getExtension(), ['pdf', 'excel']) ? $this->data : (new imageManager())->make($this->data);
|
||||
|
||||
// intervention/image v3: new
|
||||
return in_array($this->getExtension(), ['pdf', 'excel'])
|
||||
? $this->data
|
||||
: (new ImageManager(new Driver()))->read($this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +74,10 @@ class FileObject implements DataTransferObject
|
||||
*/
|
||||
public function getDecodedData(): string
|
||||
{
|
||||
// intervention/image v3: Use encode()->toDataUri() instead of encode('data-url')->encoded
|
||||
return in_array($this->getExtension(), ['pdf', 'excel']) ?
|
||||
base64_decode((explode('base64,', $this->getData()))[1]):
|
||||
$this->getData()->encode('data-url')->encoded;
|
||||
$this->getData()->encode()->toDataUri();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,17 +66,22 @@ class ConvertsBase64ToFile
|
||||
$suffix = $size !== 'original' ? '_'.$size : '';
|
||||
|
||||
if($size !== 'original') {
|
||||
$thumbnail = $file->getData()->widen($value, function ($constraint) {
|
||||
|
||||
$constraint->upsize();
|
||||
// intervention/image v2: old
|
||||
// $thumbnail = $file->getData()->widen($value, function ($constraint) {
|
||||
// $constraint->upsize();
|
||||
// })->heighten($value, function ($constraint) {
|
||||
// $constraint->upsize();
|
||||
// });
|
||||
// $file->setData($thumbnail->encode('data-url')->encoded);
|
||||
|
||||
})->heighten($value, function ($constraint) {
|
||||
|
||||
$constraint->upsize();
|
||||
// intervention/image v3: Use scaleDown() instead of widen()/heighten()
|
||||
// scaleDown() maintains aspect ratio and prevents upsizing by default
|
||||
$thumbnail = $file->getData()->scaleDown(width: $value, height: $value);
|
||||
|
||||
});
|
||||
|
||||
$file->setData($thumbnail->encode('data-url')->encoded);
|
||||
// intervention/image v3: Use encode()->toDataUri() instead of encode('data-url')->encoded
|
||||
$file->setData($thumbnail->encode()->toDataUri());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,11 +19,15 @@ class CreatesFiles extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
$models = [];
|
||||
|
||||
// foreach ($object->getFiles() as $file) {
|
||||
// $model = new File(['file' => $file]);
|
||||
// $models[] = $this->handler($document->files(), $model);
|
||||
// }
|
||||
|
||||
foreach ($object->getFiles() as $file) {
|
||||
|
||||
$model = new File(['file' => $file]);
|
||||
$fileData = is_string($file) ? json_decode($file, true) : $file;
|
||||
$model = new File(['file' => $fileData]);
|
||||
$models[] = $this->handler($document->files(), $model);
|
||||
|
||||
}
|
||||
|
||||
return $models;
|
||||
|
||||
@@ -15,6 +15,10 @@ use App\Classes\Modules\OrderSteps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\OrderSteps\Services\UpdatesOrderSteps;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (9 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class ConfirmOrderProcessor
|
||||
{
|
||||
private $canConfirmOrder;
|
||||
@@ -42,6 +46,8 @@ class ConfirmOrderProcessor
|
||||
//Only Processing Step is created at this point
|
||||
$orderStep = $order->orderSteps[0];
|
||||
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 9 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
$orderStepObject = new StepsObject(
|
||||
0,
|
||||
$orderStep->reference,
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Orders\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ConfirmOrderValidation extends AbstractValidation
|
||||
{
|
||||
@@ -26,7 +27,7 @@ class ConfirmOrderValidation extends AbstractValidation
|
||||
{
|
||||
|
||||
return [
|
||||
'id' => 'required|exists:orders,id'
|
||||
'id' => ['required', Rule::exists('orders', 'id')]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\Orders\Standards\Validators;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractValidation;
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class OrderRoleValidation extends AbstractValidation
|
||||
{
|
||||
@@ -28,8 +29,8 @@ class OrderRoleValidation extends AbstractValidation
|
||||
protected function rules(?string $type = 'POST'): array
|
||||
{
|
||||
return [
|
||||
'order_id' => 'required|exists:orders,id',
|
||||
'company_module_id' => 'required|exists:company_modules,id',
|
||||
'order_id' => ['required', Rule::exists('orders', 'id')],
|
||||
'company_module_id' => ['required', Rule::exists('company_modules', 'id')],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingList\Packages\Items\ControllersLogic;
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\Items\CreatesItem;
|
||||
use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\Items\CanCreatePackageItem;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ItemObject;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompany;
|
||||
use App\Classes\Modules\Packages\Services\FetchesPackage;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ItemObject;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\Packages\CanCreatePackageItem;
|
||||
use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage;
|
||||
use App\Http\Resources\ItemResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -21,7 +21,8 @@ class CreatePackageItemLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Created PackageItem',
|
||||
'message' => 'You have successfully created a new PackageItem'
|
||||
@@ -57,7 +58,7 @@ class CreatePackageItemLogic extends AbstractControllerLogic
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
$package = $this->fetchesPackage->execute(['id' => $request->input('package_id')]);
|
||||
@@ -73,7 +74,8 @@ class CreatePackageItemLogic extends AbstractControllerLogic
|
||||
$request->input('uom'),
|
||||
$request->input('price'),
|
||||
$request->input('total'),
|
||||
ApprovalStatus::PENDING_SUBMISSION);
|
||||
ApprovalStatus::PENDING_SUBMISSION
|
||||
);
|
||||
|
||||
$this->canCreatePackageItem->passes($object);
|
||||
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackageItems\ControllersLogic;
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -16,7 +16,8 @@ class DeletePackageItemLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Deleted PackageItem',
|
||||
'message' => 'You have successfully deleted a PackageItem'
|
||||
@@ -52,7 +53,7 @@ class DeletePackageItemLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -64,7 +65,7 @@ class DeletePackageItemLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->response([]);
|
||||
|
||||
} catch (\Exception $exception){
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackageItems\ControllersLogic;
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -17,7 +17,8 @@ class FetchPackageItemLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved PackageItem',
|
||||
'message' => 'You have successfully retrieved a PackageItem'
|
||||
@@ -47,7 +48,7 @@ class FetchPackageItemLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -57,7 +58,7 @@ class FetchPackageItemLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->resourceResponse(new ItemResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackageItems\ControllersLogic;
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -17,7 +17,8 @@ class ListPackageItemsLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Retrieved PackageItems',
|
||||
'message' => 'You have successfully retrieved a list of PackageItems'
|
||||
@@ -47,7 +48,7 @@ class ListPackageItemsLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -57,7 +58,7 @@ class ListPackageItemsLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->collectionResponse(ItemResource::collection($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
} catch (\Exception $exception) {
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackageItems\ControllersLogic;
|
||||
namespace App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
@@ -19,7 +19,8 @@ class UpdatePackageItemLogic extends AbstractControllerLogic
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
protected function notification(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Updated PackageItem',
|
||||
'message' => 'You have successfully updated the PackageItem'
|
||||
@@ -54,7 +55,7 @@ class UpdatePackageItemLogic extends AbstractControllerLogic
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
public function logic(Request $request): JsonResponse
|
||||
{
|
||||
$packageItem = $this->fetchesPackageItem->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -67,7 +68,8 @@ class UpdatePackageItemLogic extends AbstractControllerLogic
|
||||
$request->input('uom'),
|
||||
$request->input('price'),
|
||||
$request->input('total'),
|
||||
$request->input('status'));
|
||||
$request->input('status')
|
||||
);
|
||||
|
||||
$this->canUpdatePackageItem->passes($object);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
|
||||
+12
-5
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingList\Processors;
|
||||
namespace App\Classes\Modules\PackingLists\Processors;
|
||||
|
||||
use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
|
||||
use App\Classes\Modules\Orders\Processors\UpdatesOrderCurrentStepProcessor;
|
||||
@@ -21,9 +21,13 @@ use App\Models\Step;
|
||||
use App\Classes\Jobs\UnityLogin;
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Classes\General\Interfaces\Steppable;
|
||||
use function PHPSTORM_META\map;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (5 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class GenerateShippingOrderStepsProcessor
|
||||
{
|
||||
/** @var CreatesManySteps */
|
||||
@@ -44,12 +48,15 @@ class GenerateShippingOrderStepsProcessor
|
||||
}
|
||||
|
||||
|
||||
public function execute(Steppable $owner, CompanyModule $appointee, array $contract_obligation_list = []){
|
||||
public function execute(Steppable $owner, CompanyModule $appointee, array $contract_obligation_list = [])
|
||||
{
|
||||
|
||||
$obligations = $contract_obligation_list;
|
||||
|
||||
$this->createsManyStep->execute($owner, array_map(function($obligation) use ($appointee) {
|
||||
return new StepsObject($appointee->id, $obligation->name,true, $step->sequence??0, 0,0, null,0, $step->hash_id);
|
||||
$this->createsManyStep->execute($owner, array_map(function ($obligation) use ($appointee) {
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 5 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
return new StepsObject($appointee->id, $obligation->name, true, $obligation->sequence ?? 0, $obligation->hash_id ?? null);
|
||||
}, $obligations));
|
||||
|
||||
$this->updateStepProcessors->execute(OrderSteps::PROCESSING);
|
||||
|
||||
-1
@@ -10,7 +10,6 @@ use App\Classes\Modules\Orders\Services\FetchesOrder;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackageObject;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
// use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
// use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
|
||||
@@ -225,7 +225,6 @@ class FetchByTrakingNoYdPortalV2Processor
|
||||
Log::info('result (json_encoded): '.json_encode($result));
|
||||
// $content = $result['choices'][0]['message']['content'] ?? null;
|
||||
$content = $result['content'][0]['text'] ?? '[]';
|
||||
|
||||
Log::info('raw ETA/ETD content: ' . $content);
|
||||
|
||||
// Remove markdown code fences if they exist
|
||||
|
||||
-1
@@ -18,7 +18,6 @@ use App\Classes\Modules\PackingLists\Services\Containers\FetchesContainer;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\Schedules\DataTransferObjects\ScheduleObject;
|
||||
use App\Classes\Modules\Schedules\Services\CreatesSchedule;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\CreatesStep;
|
||||
use App\Classes\Modules\Transports\DataTransferObjects\TransportObject;
|
||||
use App\Classes\Modules\Transports\Services\CreatesTransport;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\PackingLists\Services;
|
||||
namespace App\Classes\Modules\PackingLists\Services\Packages\Items;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\ItemObject;
|
||||
@@ -8,7 +8,8 @@ use App\Models\Item;
|
||||
|
||||
class UpdatesItem extends AbstractUpdateRecord
|
||||
{
|
||||
public function execute(Item $model, ItemObject $object) {
|
||||
public function execute(Item $model, ItemObject $object)
|
||||
{
|
||||
|
||||
$model->name = $object->getName();
|
||||
$model->reference = $object->getReference();
|
||||
|
||||
@@ -6,11 +6,17 @@ class AddItemToConstantValueArray
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param array|string|null $array
|
||||
* @param $item
|
||||
* @return array
|
||||
*/
|
||||
public function execute($array, $item): array {
|
||||
// PHP 8.3: Ensure $array is always an array, even if JSON cast fails
|
||||
// Handle cases where value might be empty string, null, or invalid JSON
|
||||
if (!is_array($array)) {
|
||||
$array = [];
|
||||
}
|
||||
|
||||
$array[] = $item;
|
||||
sort($array);
|
||||
return $array;
|
||||
|
||||
@@ -19,7 +19,7 @@ class CreatesConstant extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
$model = new SegmentConstant();
|
||||
$model->reference = $object->getReference();
|
||||
$model->value = json_encode($object->getValue());
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($segment->constants(), $model);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,17 @@ class RemoveItemFromConstantValueArray
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param array|string|null $array
|
||||
* @param $item
|
||||
* @return array
|
||||
*/
|
||||
public function execute($array, $item): array {
|
||||
// PHP 8.3: Ensure $array is always an array, even if JSON cast fails
|
||||
// Handle cases where value might be empty string, null, or invalid JSON
|
||||
if (!is_array($array)) {
|
||||
$array = [];
|
||||
}
|
||||
|
||||
foreach($array as $key => $value){
|
||||
if($array[$key] == $item){
|
||||
unset($array[$key]);
|
||||
|
||||
@@ -18,7 +18,7 @@ class UpdatesConstant extends AbstractUpdateRecord
|
||||
public function execute(SegmentConstant $model, ConstantObject $object)
|
||||
{
|
||||
$model->reference = $object->getReference();
|
||||
$model->value = json_encode($object->getValue());
|
||||
$model->value = $object->getValue();
|
||||
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ use App\Classes\ValueObjects\Constants\OrderStatus;
|
||||
use App\Classes\ValueObjects\Constants\Steps;
|
||||
use App\Classes\ValueObjects\Constants\OrderType;
|
||||
use App\Http\Resources\StepResource;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Classes\Modules\Steps\Services\FetchesSteps;
|
||||
use App\Classes\Modules\Steps\Processors\CompletesStepProcessor;
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ use App\Classes\Modules\Orders\Processors\UpdatesOrderCurrentStepProcessor;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (9 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class CompletesStepProcessor
|
||||
{
|
||||
|
||||
@@ -52,6 +56,8 @@ class CompletesStepProcessor
|
||||
|
||||
//Unity Contract Obligation Completed Status = 3
|
||||
if(isset($completed->status) && $completed->status == OrderStatus::COMPLETE){
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 9 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
$orderStepObject = new StepsObject(
|
||||
$contractEntity->company_module_id,
|
||||
$orderStep->reference,
|
||||
|
||||
@@ -17,6 +17,10 @@ use App\Models\Order;
|
||||
use App\Models\Step;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (9 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class CreateStepsProcessor
|
||||
{
|
||||
private $canCreateStep;
|
||||
@@ -46,6 +50,8 @@ class CreateStepsProcessor
|
||||
*/
|
||||
public function execute(Order $order, string $currentStep, $appointee_id){
|
||||
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 9 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
$stepObject = new StepsObject( $appointee_id, $currentStep, true, 0, OrderStatus::PROCESSING, 0, null, 0, null);
|
||||
|
||||
$this->canCreateStep->passes($stepObject);
|
||||
|
||||
@@ -20,7 +20,10 @@ use App\Classes\Jobs\UnityLogin;
|
||||
use Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (9 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class GenerateStepsProcessor
|
||||
{
|
||||
private $updatesOrderCurrentStep;
|
||||
@@ -46,6 +49,8 @@ class GenerateStepsProcessor
|
||||
//TODO: Collect hash_id & search company module table for appointee id
|
||||
|
||||
foreach($obligations as $step){
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 9 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
$orderSteps[] = new StepsObject(
|
||||
$orderRoles[0]->company_module_id,
|
||||
$step->name,
|
||||
|
||||
@@ -14,6 +14,10 @@ use App\Classes\ValueObjects\Constants\Steps;
|
||||
use App\Models\Order;
|
||||
use App\Models\Step;
|
||||
|
||||
/**
|
||||
* @deprecated This class uses incorrect StepsObject instantiation (9 parameters instead of 4)
|
||||
* FIXME: Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
*/
|
||||
class UpdateStepsProcessor
|
||||
{
|
||||
private $canUpdateStep;
|
||||
@@ -31,6 +35,8 @@ class UpdateStepsProcessor
|
||||
|
||||
public function execute(string $currentStep){
|
||||
|
||||
// FIXME: Incorrect StepsObject instantiation - uses 9 parameters instead of correct 4-parameter pattern
|
||||
// Correct pattern: new StepsObject($appointee_id, $obligation->reference, $obligation->sequence, $obligation->hash_id)
|
||||
$orderStepsObject = new StepsObject(0,$currentStep, 0, 0, 1, 1, null, 0, null);
|
||||
|
||||
$this->canUpdateStep->passes($orderStepsObject);
|
||||
|
||||
@@ -7,22 +7,30 @@ use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Models\Step;
|
||||
use App\Models\Order;
|
||||
use App\Classes\General\Interfaces\Steppable;
|
||||
|
||||
/**
|
||||
* @deprecated This class calls undefined methods on StepsObject (getPrimary, getHashId)
|
||||
* FIXME: StepsObject only has: getAppointeeId(), getReference(), getSequence(), getObligationId()
|
||||
*/
|
||||
class CreatesManySteps extends AbstractUpdateRelationshipRecord
|
||||
{
|
||||
|
||||
public function execute(Steppable $owner, array $orderSteps) {
|
||||
public function execute(Steppable $owner, array $orderSteps)
|
||||
{
|
||||
|
||||
$orderStepsModel=[];
|
||||
foreach($orderSteps as $step){
|
||||
$orderStepsModel[]=[
|
||||
$orderStepsModel = [];
|
||||
foreach ($orderSteps as $step) {
|
||||
// FIXME: Calling undefined getter methods on StepsObject
|
||||
// StepsObject only has: getAppointeeId(), getReference(), getSequence(), getObligationId()
|
||||
$orderStepsModel[] = [
|
||||
'appointee_id' => $step->getAppointeeId(),
|
||||
'reference' => $step->getReference(),
|
||||
'primary' => $step->getPrimary(),
|
||||
'primary' => $step->getPrimary(), // UNDEFINED METHOD
|
||||
'sequence' => $step->getSequence(),
|
||||
'status' => 0,
|
||||
'contract_status' => 0,
|
||||
'unity_hash_id' => $step->getHashId(),
|
||||
'unity_hash_id' => $step->getHashId(), // UNDEFINED METHOD
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,21 @@ use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
|
||||
use App\Models\Step;
|
||||
|
||||
/**
|
||||
* @deprecated This class calls undefined methods on StepsObject (getStatus, getContractStatus, getCompletedDate)
|
||||
* FIXME: StepsObject only has: getAppointeeId(), getReference(), getSequence(), getObligationId()
|
||||
*/
|
||||
class UpdatesSteps extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
public function execute(Step $model, StepsObject $object) {
|
||||
|
||||
$model->status = $object->getStatus();
|
||||
$model->contract_status = $object->getContractStatus();
|
||||
$model->complete_date = $object->getCompletedDate();
|
||||
// FIXME: Calling undefined getter methods on StepsObject
|
||||
// StepsObject only has: getAppointeeId(), getReference(), getSequence(), getObligationId()
|
||||
// The following methods DO NOT EXIST:
|
||||
$model->status = $object->getStatus(); // UNDEFINED METHOD
|
||||
$model->contract_status = $object->getContractStatus(); // UNDEFINED METHOD
|
||||
$model->complete_date = $object->getCompletedDate(); // UNDEFINED METHOD
|
||||
|
||||
return $this->handler($model);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\Transports\Services;
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Transport;
|
||||
|
||||
class updatesTransportStatus extends AbstractUpdateRecord
|
||||
class UpdatesTransportStatus extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,8 @@ class updatesTransportStatus extends AbstractUpdateRecord
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(Transport $model, int $status) {
|
||||
public function execute(Transport $model, int $status)
|
||||
{
|
||||
|
||||
$model->status = $status;
|
||||
|
||||
|
||||
@@ -22,4 +22,8 @@ class SegmentConstants
|
||||
public const OUTSTATION_POSTCODE = 'OUTSTATION_POSTCODE';
|
||||
|
||||
public const CUSTOMER_RATE = 'CUSTOMER_RATE';
|
||||
|
||||
public const SERVICE_TYPE = 'SERVICE_TYPE'; //syntax fix, likely no longer used
|
||||
|
||||
public const CUSTOM_SERVICE_TYPE = 'CUSTOM_SERVICE_TYPE'; //syntax fix, likely no longer used
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class ProcessYDPortalDataV2Command extends Command
|
||||
$jobs1 = $this->fetchPackingListsFromYdPortalV2CommandJobs();
|
||||
$jobs2 = $this->fetchContainersYdPortalV3CommandJobs();
|
||||
$jobs3 = $this->fetchContainersUpdatesYdPortalV3CommandJob();
|
||||
$jobs4 = $this->fetchDeliveryUpdatesFromYdPortalV2CommandJobs();
|
||||
// $jobs4 = $this->fetchDeliveryUpdatesFromYdPortalV2CommandJobs();
|
||||
|
||||
// The following job is intentionally excluded
|
||||
////$jobs5 = array_merge($jobs, $this->fetchOrderListsFromYdPortalV2CommandJob());
|
||||
@@ -66,10 +66,10 @@ class ProcessYDPortalDataV2Command extends Command
|
||||
dispatch($job);
|
||||
}
|
||||
|
||||
foreach ($jobs4 as $index => $job) {
|
||||
$delayInSeconds = intdiv($index, 2);
|
||||
dispatch($job)->delay(now()->addSeconds($delayInSeconds));
|
||||
}
|
||||
// foreach ($jobs4 as $index => $job) {
|
||||
// $delayInSeconds = intdiv($index, 2);
|
||||
// dispatch($job)->delay(now()->addSeconds($delayInSeconds));
|
||||
// }
|
||||
}
|
||||
|
||||
private function fetchPackingListsFromYdPortalV2CommandJobs(){
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Classes\Jobs\FetchContainersStatusUpdateFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchDeliveryListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchLoadedContainersFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchPackingListFromVTPortalJob;
|
||||
use App\Classes\Jobs\FetchWarehouseReceiveListFromVTPortalJob;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//Commands Version 2: Laravel Vapor with AWS
|
||||
$isEnabled = env('COMMANDS_V2_ENABLED', false);
|
||||
if($isEnabled){
|
||||
// $schedule->command('dummy-command')
|
||||
// ->everyFiveMinutes()
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('housekeeping-s3-files-command')
|
||||
->dailyAt('01:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('password-reset-token-expriration-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('new-user-registration-expire-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
if(env('APP_ENV') === 'production'){
|
||||
$schedule->command('curl-vt-command')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
// $schedule->command('curl-yd-order-list-command')
|
||||
// ->cron('0 9-18/3 * * *')
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-yd-by-traking-no-data-command')
|
||||
->cron('0 8,11,14,17 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-yd-portal-data-command')
|
||||
->cron('0 9,12,15,18 * * *') //->cron('0 9-18/3 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('fix-packinglist-command')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('fix-duplicate-container-reference-command')
|
||||
->cron('0 1 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
// $schedule->command('invoice-generate-command')
|
||||
// ->hourly()
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('invoice-generate-command')
|
||||
->cron('0 0-8,10-11,13-14,16-17,19-23 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('billplz-failed-callback-fix-command')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('check-storage-invoices-group-transactions-command')
|
||||
->dailyAt('0:01')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('permits-reminder-send-command')
|
||||
->dailyAt('09:30')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-delayed-jobs-command')
|
||||
->everyFiveMinutes()
|
||||
->withoutOverlapping();
|
||||
}
|
||||
else if (env('APP_ENV') === 'development'){
|
||||
$schedule->command('process-delayed-jobs-command')
|
||||
->everyTwoHours()
|
||||
->withoutOverlapping();
|
||||
}
|
||||
}
|
||||
//Commands Version 1: Before AWS
|
||||
else
|
||||
{
|
||||
$schedule->command('command:curlVTCommand')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlvt.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/curlyd.log');
|
||||
|
||||
$schedule->command('fix-packinglist')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/fix_packinglist.log');
|
||||
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('0 9 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo (storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('fix-duplicate-container-reference')
|
||||
->cron('0 1 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/fix_duplicate_container_reference.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/auto_generate_invoice.log');
|
||||
|
||||
$schedule->command('billplz-failed-callback:fix')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo (storage_path().'/logs/fix_failed_callback_from_billplz.log');
|
||||
|
||||
$schedule->command('check-storage-invoices-group-transactions')
|
||||
->dailyAt('0:01')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path().'/logs/check_storage_invoices.log');
|
||||
|
||||
$schedule->command('permitsReminder:send')
|
||||
->dailyAt('09:30')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path().'/logs/permits-reminder-send.log');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__.'/Commands/V2');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
if (env('LOG_STACK_TRACE', false)) {
|
||||
Log::error($exception->getMessage(), [
|
||||
'exception' => $exception,
|
||||
'stack_trace' => $exception->getTraceAsString(),
|
||||
]);
|
||||
}
|
||||
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Throwable $exception
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
if ($exception instanceof MaintenanceModeException) {
|
||||
return response()
|
||||
->view('pages.errors.maintenance');
|
||||
}
|
||||
|
||||
if ($exception instanceof AuthenticationException) {
|
||||
return (new ApiResponseObject('Authentication', 'To keep your account secure we need to re-validate your account', HttpStatus::ACCESS_UNAUTHORISED))->handler();
|
||||
}
|
||||
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
@@ -19,33 +19,33 @@ class ExportArrivedParcelController extends Controller
|
||||
{
|
||||
/**
|
||||
* ExportArrivedParcelController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth.check');
|
||||
// $token = Auth::fromUser(User::find(1));
|
||||
// $request->headers->set('Authorization', 'Bearer '.$token);
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->query('start_date');
|
||||
$endDate = $request->query('end_date');
|
||||
|
||||
$exportsPendingArrangementDeliveryList = new ExportsArrivedParcel($startDate, $endDate);
|
||||
$exportFileName = 'arrived-parcel.xlsx';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList)]);
|
||||
} else {
|
||||
$response = $exportsPendingArrangementDeliveryList->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function summary(Request $request) {
|
||||
public function summary(Request $request)
|
||||
{
|
||||
|
||||
$validated = $request->validate([
|
||||
'startDate' => 'nullable|date_format:d-m-Y',
|
||||
@@ -66,38 +66,37 @@ class ExportArrivedParcelController extends Controller
|
||||
$exportsParcelsSummary = new ExportsParcel($startDate, $endDate);
|
||||
$exportFileName = 'parcel-summary.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsParcelsSummary) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsParcelsSummary)]);
|
||||
} else {
|
||||
$response = $exportsParcelsSummary->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function guangZhou2ToJohor(Request $request) {
|
||||
public function guangZhou2ToJohor(Request $request)
|
||||
{
|
||||
$exportsWarehousePackingList = new ExportsWarehousePackingList();
|
||||
$exportFileName = 'guangzhou2-to-johor-summary.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsWarehousePackingList) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsWarehousePackingList)]);
|
||||
} else {
|
||||
$response = $exportsWarehousePackingList->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function aging(Request $request) {
|
||||
public function aging(Request $request)
|
||||
{
|
||||
$data = new ExportsAgingList();
|
||||
$exportFileName = 'aging_report.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $data) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $data)]);
|
||||
} else {
|
||||
$response = $data->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
|
||||
@@ -15,35 +15,34 @@ class ExportPendingArrangementPackingListController extends Controller
|
||||
{
|
||||
/**
|
||||
* ExportPendingArrangementPackingListController constructor.
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth.check');
|
||||
}
|
||||
|
||||
public function export(Request $request) {
|
||||
public function export(Request $request)
|
||||
{
|
||||
$exportsPendingArrangementDeliveryList = new ExportsPendingArrangementDeliveryList($request);
|
||||
$exportFileName = 'packing-list-delivery.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList)]);
|
||||
} else {
|
||||
$response = $exportsPendingArrangementDeliveryList->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
public function onHold(Request $request) {
|
||||
public function onHold(Request $request)
|
||||
{
|
||||
$exportsPendingArrangementDeliveryList = new ExportsOnHoldPackingList($request);
|
||||
$exportFileName = 'packing-list-on-hold.xls';
|
||||
$filesystemDriver = Storage::getDefaultDriver();
|
||||
if($filesystemDriver === 's3'){
|
||||
return response([ 'src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList) ]);
|
||||
}
|
||||
else{
|
||||
if ($filesystemDriver === 's3') {
|
||||
return response(['src' => AWSS3Helper::S3Exportable($exportFileName, $exportsPendingArrangementDeliveryList)]);
|
||||
} else {
|
||||
$response = $exportsPendingArrangementDeliveryList->download($exportFileName, Excel::XLS, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
|
||||
ob_end_clean();
|
||||
return $response;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages\items;
|
||||
namespace App\Http\Controllers\PackingLists\Packages\Items;
|
||||
|
||||
use App\Classes\Modules\PackageItems\ControllersLogic\CreatePackageItemLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items\CreatePackageItemLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -13,7 +13,8 @@ class CreatePackageItemController
|
||||
* @param CreatePackageItemLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request, CreatePackageItemLogic $logic): JsonResponse {
|
||||
public function create(Request $request, CreatePackageItemLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages\items;
|
||||
namespace App\Http\Controllers\PackingLists\Packages\Items;
|
||||
|
||||
use App\Classes\Modules\PackageItems\ControllersLogic\DeletePackageItemLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items\DeletePackageItemLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -13,7 +13,8 @@ class DeletePackageItemController
|
||||
* @param DeletePackageItemLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function delete(Request $request, DeletePackageItemLogic $logic): JsonResponse {
|
||||
public function delete(Request $request, DeletePackageItemLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages\items;
|
||||
namespace App\Http\Controllers\PackingLists\Packages\Items;
|
||||
|
||||
use App\Classes\Modules\PackageItems\ControllersLogic\FetchPackageItemLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items\FetchPackageItemLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -13,7 +13,8 @@ class FetchPackageItemController
|
||||
* @param FetchPackageItemLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchPackageItemLogic $logic): JsonResponse {
|
||||
public function fetch(Request $request, FetchPackageItemLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages\items;
|
||||
namespace App\Http\Controllers\PackingLists\Packages\Items;
|
||||
|
||||
use App\Classes\Modules\PackageItems\ControllersLogic\ListPackageItemsLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items\ListPackageItemsLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -10,10 +10,11 @@ class ListPackageItemsController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListPackageItemLogic $logic
|
||||
* @param ListPackageItemsLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListPackageItemsLogic $logic): JsonResponse {
|
||||
public function list(Request $request, ListPackageItemsLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\PackingLists\Packages\items;
|
||||
namespace App\Http\Controllers\PackingLists\Packages\Items;
|
||||
|
||||
use App\Classes\Modules\PackageItems\ControllersLogic\UpdatePackageItemLogic;
|
||||
use App\Classes\Modules\PackingLists\ControllersLogic\Packages\Items\UpdatePackageItemLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -13,7 +13,8 @@ class UpdatePackageItemController
|
||||
* @param UpdatePackageItemLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdatePackageItemLogic $logic): JsonResponse {
|
||||
public function update(Request $request, UpdatePackageItemLogic $logic): JsonResponse
|
||||
{
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class CreatePermitsReminderController
|
||||
{
|
||||
@@ -19,7 +20,7 @@ class CreatePermitsReminderController
|
||||
{
|
||||
// Define validation rules
|
||||
$rules = [
|
||||
'model' => 'required|unique:permits_reminders,model',
|
||||
'model' => ['required', Rule::unique('permits_reminders', 'model')],
|
||||
'expiry_date' => 'required|date|after_or_equal:today',
|
||||
'reminder_date' => 'required|date|after_or_equal:today',
|
||||
];
|
||||
|
||||
@@ -7,6 +7,7 @@ use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdatePermitsReminderController
|
||||
{
|
||||
@@ -17,7 +18,7 @@ class UpdatePermitsReminderController
|
||||
public function update(Request $request): JsonResponse
|
||||
{
|
||||
$rules = [
|
||||
'model' => 'required|unique:permits_reminders,model,' . $request->route('id'),
|
||||
'model' => ['required', Rule::unique('permits_reminders', 'model')->ignore($request->route('id'))],
|
||||
'expiry_date' => 'required|date|after_or_equal:today',
|
||||
'reminder_date' => 'required|date|after_or_equal:today',
|
||||
];
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\ValidateToken;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:300,1',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'apipub' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'valid.token' => ValidateToken::class,
|
||||
'token.check' => \App\Http\Middleware\TokenCheckerMiddleware::class,
|
||||
'auth.check' => \App\Http\Middleware\CheckAuthorizationMiddleware::class,
|
||||
'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class,
|
||||
'storage.invoice.check.bytransaction' => \App\Http\Middleware\CheckForStorageInvoiceByTransactionId::class,
|
||||
'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class,
|
||||
'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class,
|
||||
'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class,
|
||||
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class, //cief maintenance
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Classes\General\LogHelper;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogRequestPathMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if(env('APP_ENV') !== 'local'){
|
||||
$method = $request->method();
|
||||
$fullUrl = $request->fullUrl();
|
||||
LogHelper::channel('request_path')->info('Request Method: ' . $method);
|
||||
LogHelper::channel('request_path')->info('Request URL: ' . $fullUrl);
|
||||
|
||||
|
||||
if ($request->isMethod('post')) {
|
||||
$payload = $request->all();
|
||||
LogHelper::channel('request_path')->info('Request Payload POST: ', $payload);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -23,7 +22,7 @@ class RedirectIfAuthenticated
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
|
||||
@@ -11,19 +11,6 @@ use Tymon\JWTAuth\JWT;
|
||||
|
||||
class ValidateToken
|
||||
{
|
||||
/** @var JWT */
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* ValidateToken constructor.
|
||||
* @param JWT $manager
|
||||
*/
|
||||
public function __construct(JWT $manager)
|
||||
{
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if jwt token is valid.
|
||||
*
|
||||
@@ -35,7 +22,9 @@ class ValidateToken
|
||||
{
|
||||
try {
|
||||
|
||||
if(!$this->manager->check()){ throw new AccessUnauthorisedException(); }
|
||||
if (!auth('api')->check()) {
|
||||
throw new AccessUnauthorisedException();
|
||||
}
|
||||
|
||||
} catch (Exception $exception) {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Logging;
|
||||
|
||||
use Aws\CloudWatchLogs\CloudWatchLogsClient;
|
||||
use Maxbanton\Cwh\Handler\CloudWatch;
|
||||
use PhpNexus\Cwh\Handler\CloudWatch;
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
use Monolog\Logger;
|
||||
|
||||
|
||||
@@ -6,12 +6,21 @@ namespace App\Models;
|
||||
use App\Classes\General\Interfaces\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class AbstractModel extends Model implements Notifiable
|
||||
{
|
||||
use LogsActivity;
|
||||
protected static $logFillable = true;
|
||||
|
||||
/**
|
||||
* Get the options for logging activity.
|
||||
*/
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphTo
|
||||
|
||||
+17
-9
@@ -15,14 +15,17 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
* Class Address
|
||||
* @package App\Models
|
||||
*
|
||||
* @property int country_id
|
||||
* @property int company_id
|
||||
* @property int state_id
|
||||
* @property int district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $country_id
|
||||
* @property int $state_id
|
||||
* @property int $district_id
|
||||
* @property string $postcode
|
||||
* @property string $street_one
|
||||
* @property string $street_two
|
||||
* @property int $billing_type
|
||||
*
|
||||
* @property \App\Models\Country $country
|
||||
* @property \App\Models\State $state
|
||||
* @property \App\Models\District $district
|
||||
*/
|
||||
class Address extends AbstractModel implements Contactable, Remarkable
|
||||
{
|
||||
@@ -30,7 +33,12 @@ class Address extends AbstractModel implements Contactable, Remarkable
|
||||
|
||||
protected $table = 'addresses';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $fillable = ['default'];
|
||||
|
||||
|
||||
+13
-8
@@ -16,13 +16,13 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
* Class Company
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property \App\Models\District district_id
|
||||
* @property string postcode
|
||||
* @property string street_one
|
||||
* @property string street_two
|
||||
* @property integer billing_type
|
||||
* @property int $country_id
|
||||
* @property int $state_id
|
||||
* @property int $district_id
|
||||
* @property string $postcode
|
||||
* @property string $street_one
|
||||
* @property string $street_two
|
||||
* @property int $billing_type
|
||||
*/
|
||||
class Company extends AbstractModel implements Documentable, Contactable
|
||||
{
|
||||
@@ -31,7 +31,12 @@ class Company extends AbstractModel implements Documentable, Contactable
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
|
||||
@@ -20,12 +20,15 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use PhpParser\Node\Expr\AssignOp\Mod;
|
||||
|
||||
/**
|
||||
* Class CompanyModule
|
||||
* Class CompanyConnection
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property integer type
|
||||
* @property integer status
|
||||
* @property int $inviter_id
|
||||
* @property int $invitee_id
|
||||
* @property string $inviter_reference
|
||||
* @property string $invitee_reference
|
||||
* @property int $status
|
||||
* @property bool $is_credit_term
|
||||
*/
|
||||
class CompanyConnection extends AbstractModel
|
||||
{
|
||||
@@ -33,7 +36,12 @@ class CompanyConnection extends AbstractModel
|
||||
|
||||
protected $table = 'company_connections';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -9,10 +9,13 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
* Class CompanyEmployee
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\companyModule company_module_id
|
||||
* @property \App\Models\User user_id
|
||||
* @property integer role_id
|
||||
* @property integer status
|
||||
* @property int $company_module_id
|
||||
* @property int $user_id
|
||||
* @property int $role_id
|
||||
* @property int $status
|
||||
*
|
||||
* @property \App\Models\CompanyModule $companyModule
|
||||
* @property \App\Models\User $user
|
||||
*/
|
||||
class CompanyEmployee extends AbstractModel
|
||||
{
|
||||
|
||||
@@ -29,9 +29,11 @@ use App\Classes\General\Interfaces\Remarkable;
|
||||
* Class CompanyModule
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property integer type
|
||||
* @property integer status
|
||||
* @property int $company_id
|
||||
* @property int $type
|
||||
* @property int $status
|
||||
*
|
||||
* @property \App\Models\Company $company
|
||||
*/
|
||||
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner, Packable, Remarkable
|
||||
{
|
||||
@@ -40,7 +42,12 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
|
||||
protected $table = 'company_modules';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
@@ -95,7 +102,7 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
*/
|
||||
public function invites(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CompanyModule::class, CompanyConnection::class,'inviter_id', 'invitee_id');
|
||||
return $this->belongsToMany(CompanyModule::class, CompanyConnection::class, 'inviter_id', 'invitee_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,11 +110,12 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
|
||||
*/
|
||||
public function inviters(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CompanyModule::class, CompanyConnection::class,'invitee_id', 'inviter_id');
|
||||
return $this->belongsToMany(CompanyModule::class, CompanyConnection::class, 'invitee_id', 'inviter_id');
|
||||
}
|
||||
|
||||
|
||||
public function connections(): hasMany {
|
||||
public function connections(): hasMany
|
||||
{
|
||||
return $this->hasMany(CompanyConnection::class, 'invitee_id');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class Segment
|
||||
* Class ConnectionSegment
|
||||
* @package App\Models
|
||||
*
|
||||
* @property string name
|
||||
* @property string reference
|
||||
* @property string $name
|
||||
* @property string $reference
|
||||
*/
|
||||
class ConnectionSegment extends AbstractModel
|
||||
{
|
||||
@@ -18,7 +18,12 @@ class ConnectionSegment extends AbstractModel
|
||||
|
||||
protected $table = 'connection_segments';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
|
||||
+16
-8
@@ -9,13 +9,16 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
* Class Contact
|
||||
* @package App\Models
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property string owner_type
|
||||
* @property string reference
|
||||
* @property string phone
|
||||
* @property string email
|
||||
* @property string wechat_id
|
||||
* @property int default
|
||||
* @property int $id
|
||||
* @property int $owner_id
|
||||
* @property string $owner_type
|
||||
* @property string $reference
|
||||
* @property string $phone
|
||||
* @property string $email
|
||||
* @property string $wechat_id
|
||||
* @property int $default
|
||||
*
|
||||
* @property mixed $owner
|
||||
*/
|
||||
class Contact extends AbstractModel
|
||||
{
|
||||
@@ -23,7 +26,12 @@ class Contact extends AbstractModel
|
||||
|
||||
protected $table = 'contacts';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
|
||||
@@ -21,7 +21,12 @@ class Container extends AbstractModel implements Transportable, Remarkable
|
||||
|
||||
protected $fillable = ['status'];
|
||||
|
||||
protected $dates = ['loading_date'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'loading_date' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function packingLists(): belongsToMany
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class Country
|
||||
* @package App\Models
|
||||
*
|
||||
* @property string name
|
||||
* @property string short_code
|
||||
* @property string phone_code
|
||||
* @property string $name
|
||||
* @property string $short_code
|
||||
* @property string $phone_code
|
||||
*/
|
||||
class Country extends AbstractModel
|
||||
{
|
||||
@@ -19,7 +19,12 @@ class Country extends AbstractModel
|
||||
|
||||
protected $table = 'countries';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $fillable = ['name', 'short_code', 'phone_code'];
|
||||
|
||||
|
||||
+14
-5
@@ -12,10 +12,14 @@ use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
* Class Currency
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property string name
|
||||
* @property string short_code
|
||||
* @property string symbol
|
||||
* @property int $id
|
||||
* @property int $country_id
|
||||
* @property string $name
|
||||
* @property string $short_code
|
||||
* @property string $symbol
|
||||
*
|
||||
* @property \App\Models\Country $country
|
||||
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\CurrencyRate[] $rates
|
||||
*/
|
||||
|
||||
class Currency extends AbstractModel
|
||||
@@ -24,7 +28,12 @@ class Currency extends AbstractModel
|
||||
|
||||
protected $table = 'currencies';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -12,5 +12,10 @@ class CurrencyRate extends AbstractModel
|
||||
|
||||
protected $fillable = ['currency_id', 'selling', 'payment_method_type'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+13
-5
@@ -10,10 +10,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class District
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property \App\Models\State state_id
|
||||
* @property string name
|
||||
* @property string postcode
|
||||
* @property int $country_id
|
||||
* @property int $state_id
|
||||
* @property string $name
|
||||
* @property string $postcode
|
||||
*
|
||||
* @property \App\Models\Country $country
|
||||
* @property \App\Models\State $state
|
||||
*/
|
||||
class District extends AbstractModel
|
||||
{
|
||||
@@ -21,7 +24,12 @@ class District extends AbstractModel
|
||||
|
||||
protected $table = 'districts';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
+15
-10
@@ -14,15 +14,15 @@ use Illuminate\Database\Eloquent\Relations\hasMany;
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property int owner_id
|
||||
* @property int owner_type
|
||||
* @property int document_type
|
||||
* @property string reference
|
||||
* @property int status
|
||||
* @property \App\Models\User approver
|
||||
* @property timestamp issued_date
|
||||
* @property timestamp expired_date
|
||||
* @property timestamp approved_date
|
||||
* @property int $owner_id
|
||||
* @property string $owner_type
|
||||
* @property string $document_type
|
||||
* @property string $reference
|
||||
* @property int $status
|
||||
* @property int $approver
|
||||
* @property \Carbon\Carbon $issued_date
|
||||
* @property \Carbon\Carbon $expired_date
|
||||
* @property \Carbon\Carbon $approval_date
|
||||
*/
|
||||
class Document extends AbstractModel
|
||||
{
|
||||
@@ -30,7 +30,12 @@ class Document extends AbstractModel
|
||||
|
||||
protected $table = 'documents';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
|
||||
@@ -7,11 +7,15 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* Class CompanyEmployee
|
||||
* @package App\Models
|
||||
* Class Employee
|
||||
* @package App\Models\Exchange
|
||||
*
|
||||
* @property \App\Models\Company company_id
|
||||
* @property \App\Models\User user_id
|
||||
* @property int $id
|
||||
* @property int $company_id
|
||||
* @property int $user_id
|
||||
*
|
||||
* @property \Illuminate\Database\Eloquent\Collection|\App\Models\Exchange\Company[] $company
|
||||
* @property \App\Models\Exchange\User $user
|
||||
*/
|
||||
class Employee extends AbstractModel
|
||||
{
|
||||
|
||||
+9
-7
@@ -10,9 +10,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @package App\Models
|
||||
* @version August 4, 2020, 4:36 am
|
||||
*
|
||||
* @property \App\Models\Document document_id
|
||||
* @property text file
|
||||
* @property int file_type_id
|
||||
* @property int $document_id
|
||||
* @property array $file
|
||||
* @property int $file_type_id
|
||||
*/
|
||||
class File extends AbstractModel
|
||||
{
|
||||
@@ -22,10 +22,12 @@ class File extends AbstractModel
|
||||
|
||||
protected $fillable = ['file'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function getFileAttribute($value)
|
||||
protected function casts(): array
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
return [
|
||||
'file' => 'array',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,12 @@ class KeyValuePair extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $table = 'key_value_pairs';
|
||||
|
||||
|
||||
+27
-15
@@ -27,7 +27,12 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,26 +102,27 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
// if (auth()->user()->type === RoleTypes::USER) {
|
||||
// if (auth()->user()->type === RoleTypes::USER) {
|
||||
// static::addGlobalScope(new CustomerOrdersScope);
|
||||
// }
|
||||
}
|
||||
|
||||
public function addressesPendingVerification()
|
||||
{
|
||||
return $this->addresses()->where('status','=',ApprovalStatus::PENDING_VERIFICATION);
|
||||
return $this->addresses()->where('status', '=', ApprovalStatus::PENDING_VERIFICATION);
|
||||
}
|
||||
|
||||
public function addressesApproved()
|
||||
{
|
||||
return $this->addresses()->where('status','=',ApprovalStatus::APPROVED);
|
||||
return $this->addresses()->where('status', '=', ApprovalStatus::APPROVED);
|
||||
}
|
||||
|
||||
public function originWarehousePackages()
|
||||
{
|
||||
return $this->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereDoesntHave('shippingSchedules',
|
||||
function($schedule) {
|
||||
->whereDoesntHave(
|
||||
'shippingSchedules',
|
||||
function ($schedule) {
|
||||
return $schedule->dispatched()
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
@@ -126,13 +132,16 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
public function inTransitPackages()
|
||||
{
|
||||
return $this->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST)->Shipping()
|
||||
->whereHas('shippingSchedules',
|
||||
function($schedule) {
|
||||
->whereHas(
|
||||
'shippingSchedules',
|
||||
function ($schedule) {
|
||||
return $schedule->dispatched()
|
||||
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
)
|
||||
->whereDoesntHave('containers', function($container) {
|
||||
->whereDoesntHave(
|
||||
'containers',
|
||||
function ($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)->whereHas('packages');
|
||||
@@ -141,13 +150,15 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
public function destinationWarehousePackages()
|
||||
{
|
||||
return $this->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereHas('containers',
|
||||
function($container) {
|
||||
->whereHas(
|
||||
'containers',
|
||||
function ($container) {
|
||||
return $container->where('containers.status', ApprovalStatus::COMPLETED);
|
||||
}
|
||||
)
|
||||
->whereDoesntHave('deliverySchedules',
|
||||
function($schedule) {
|
||||
->whereDoesntHave(
|
||||
'deliverySchedules',
|
||||
function ($schedule) {
|
||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
)->whereHas('packages');
|
||||
@@ -156,8 +167,9 @@ class Order extends AbstractModel implements Addressable, Packable, Remarkable,
|
||||
public function deliveredPackages()
|
||||
{
|
||||
return $this->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST)
|
||||
->whereHas('deliverySchedules',
|
||||
function($schedule) {
|
||||
->whereHas(
|
||||
'deliverySchedules',
|
||||
function ($schedule) {
|
||||
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -12,7 +12,12 @@ class PermitsReminder extends Model
|
||||
|
||||
protected $table = 'permits_reminders';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected $fillable = ['model', 'expiry_date', 'reminder_date'];
|
||||
|
||||
|
||||
+11
-3
@@ -14,7 +14,13 @@ class Schedule extends AbstractModel
|
||||
|
||||
protected $table = 'schedules';
|
||||
|
||||
protected $dates = ['etd', 'eta'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'etd' => 'datetime',
|
||||
'eta' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
@@ -30,7 +36,8 @@ class Schedule extends AbstractModel
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDispatched($query){
|
||||
public function scopeDispatched($query)
|
||||
{
|
||||
return $query->where('etd', '<', Carbon::now());
|
||||
}
|
||||
|
||||
@@ -38,7 +45,8 @@ class Schedule extends AbstractModel
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDropped($query){
|
||||
public function scopeDropped($query)
|
||||
{
|
||||
return $query->where('eta', '<', Carbon::now());
|
||||
}
|
||||
}
|
||||
|
||||
+15
-10
@@ -9,8 +9,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class Segment
|
||||
* @package App\Models
|
||||
*
|
||||
* @property string name
|
||||
* @property string reference
|
||||
* @property string $name
|
||||
* @property string $reference
|
||||
*/
|
||||
class Segment extends AbstractModel
|
||||
{
|
||||
@@ -18,7 +18,12 @@ class Segment extends AbstractModel
|
||||
|
||||
protected $table = 'segments';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
@@ -28,11 +33,11 @@ class Segment extends AbstractModel
|
||||
return $this->HasMany(SegmentConstant::class, 'segment_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return belongsToMany
|
||||
*/
|
||||
public function companyConnections(): belongsToMany
|
||||
{
|
||||
return $this->belongsToMany(CompanyConnection::class, (new ConnectionSegment())->getTable(), 'segment_id', 'company_connection_id');
|
||||
}
|
||||
// /**
|
||||
// * @return belongsToMany
|
||||
// */
|
||||
// public function companyConnections(): belongsToMany
|
||||
// {
|
||||
// return $this->belongsToMany(CompanyConnection::class, (new ConnectionSegment())->getTable(), 'segment_id', 'company_connection_id');
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -10,8 +10,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class SegmentConstant
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Segment segment_id
|
||||
* @property string detail
|
||||
* @property int $id
|
||||
* @property int $segment_id
|
||||
* @property string $reference
|
||||
* @property array $detail
|
||||
* @property array $value
|
||||
*/
|
||||
class SegmentConstant extends AbstractModel
|
||||
{
|
||||
@@ -19,9 +22,13 @@ class SegmentConstant extends AbstractModel
|
||||
|
||||
protected $table = 'segment_constants';
|
||||
|
||||
public function getDetailAttribute($value)
|
||||
protected function casts(): array
|
||||
{
|
||||
return $value ? json_decode($value) : [];
|
||||
return [
|
||||
'detail' => 'array',
|
||||
'value' => 'array',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,9 +39,4 @@ class SegmentConstant extends AbstractModel
|
||||
return $this->BelongsTo(Segment::class, 'segment_id', 'id');
|
||||
}
|
||||
|
||||
public function getValueAttribute($value)
|
||||
{
|
||||
$value = $value ? json_decode($value) : [];
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @package App\Models
|
||||
* @version February 16, 2021, 9:04 pm
|
||||
*
|
||||
* @property string name
|
||||
* @property string $name
|
||||
*/
|
||||
class ServiceType extends AbstractModel
|
||||
{
|
||||
@@ -25,10 +25,6 @@ class ServiceType extends AbstractModel
|
||||
|
||||
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
public $fillable = [
|
||||
'name'
|
||||
];
|
||||
@@ -38,9 +34,13 @@ class ServiceType extends AbstractModel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'name' => 'string'
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'string',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
|
||||
@@ -9,8 +9,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* Class State
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\Country country_id
|
||||
* @property string name
|
||||
* @property int $country_id
|
||||
* @property string $name
|
||||
*/
|
||||
class State extends AbstractModel
|
||||
{
|
||||
@@ -18,7 +18,12 @@ class State extends AbstractModel
|
||||
|
||||
protected $table = 'states';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
+6
-1
@@ -14,7 +14,12 @@ class Step extends AbstractModel
|
||||
|
||||
protected $fillable = ['status'];
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function owner(): morphTo
|
||||
{
|
||||
|
||||
@@ -23,9 +23,12 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
use SoftDeletes;
|
||||
use LogData;
|
||||
|
||||
protected $casts = [
|
||||
'type' => 'int'
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'int',
|
||||
];
|
||||
}
|
||||
|
||||
protected $table = 'transactions';
|
||||
|
||||
@@ -95,12 +98,12 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
*/
|
||||
public function groupsWithTrashed(): BelongsToMany
|
||||
{
|
||||
return $this->BelongsToMany(Group::class, GroupTransaction::class, 'transaction_id')->withTrashed();;
|
||||
return $this->BelongsToMany(Group::class, GroupTransaction::class, 'transaction_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function convert_original_amount()
|
||||
{
|
||||
if($this->booking()->first()->fix_currency_id !== 1) {
|
||||
if ($this->booking()->first()->fix_currency_id !== 1) {
|
||||
$currency_rate = $this->currency()->first()->rates()->where('payment_method_type', $this->payment_method)->first();
|
||||
|
||||
return number_format($this->original_amount / $currency_rate->selling, 2);
|
||||
@@ -123,11 +126,11 @@ class Transaction extends AbstractModel implements Documentable, Transactionable
|
||||
*/
|
||||
public function scopeInComplete(Builder $query)
|
||||
{
|
||||
return $query->where(function(Builder $query){
|
||||
$query->where(function(Builder $query){
|
||||
return $query->where(function (Builder $query) {
|
||||
$query->where(function (Builder $query) {
|
||||
$query->where('status', ApprovalStatus::PENDING_SUBMISSION)
|
||||
->whereDate('expires_on', '>=', Carbon::now());
|
||||
})->orWhere(function(Builder $query){
|
||||
})->orWhere(function (Builder $query) {
|
||||
$query->where('status', ApprovalStatus::PENDING_VERIFICATION);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,13 @@ class Transport extends AbstractModel
|
||||
|
||||
protected $fillable = ['status', 'drop_date'];
|
||||
|
||||
protected $dates = ['dispatch_date', 'drop_date'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'dispatch_date' => 'datetime',
|
||||
'drop_date' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
@@ -38,7 +44,8 @@ class Transport extends AbstractModel
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDispatched($query){
|
||||
public function scopeDispatched($query)
|
||||
{
|
||||
return $query->where('dispatch_date', '<', Carbon::now())->whereIn('status', [ApprovalStatus::APPROVED]);
|
||||
}
|
||||
|
||||
@@ -46,7 +53,8 @@ class Transport extends AbstractModel
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeDropped($query){
|
||||
public function scopeDropped($query)
|
||||
{
|
||||
return $query->where('drop_date', '<', Carbon::now())->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-3
@@ -27,7 +27,12 @@ class User extends AbstractModel implements
|
||||
{
|
||||
use HasRoles, Notifiable, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||
@@ -49,14 +54,16 @@ class User extends AbstractModel implements
|
||||
return [];
|
||||
}
|
||||
|
||||
public function emailVerification(): HasMany {
|
||||
public function emailVerification(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserEmailVerification::class, 'email', 'email');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function passwordReset(): HasMany {
|
||||
public function passwordReset(): HasMany
|
||||
{
|
||||
return $this->hasMany(PasswordReset::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,15 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class District
|
||||
* Class UserSocialAccount
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\User user_id
|
||||
* @property string app_id
|
||||
* @property int platform
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $app_id
|
||||
* @property int $platform
|
||||
*
|
||||
* @property \App\Models\User $user
|
||||
*/
|
||||
class UserSocialAccount extends AbstractModel
|
||||
{
|
||||
@@ -20,7 +23,12 @@ class UserSocialAccount extends AbstractModel
|
||||
|
||||
protected $table = 'user_social_accounts';
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -25,5 +28,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(300)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* The controller namespace for the application.
|
||||
*
|
||||
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $namespace = 'App\\Http\\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::prefix('public/api')
|
||||
->middleware('apipub')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/apipub.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
+196
-36
@@ -11,45 +11,205 @@
|
||||
|
|
||||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__ . '/../routes/web.php',
|
||||
api: __DIR__ . '/../routes/api.php',
|
||||
commands: __DIR__ . '/../routes/console.php',
|
||||
health: '/up',
|
||||
then: function () {
|
||||
Route::prefix('public/api')
|
||||
->middleware('apipub')
|
||||
->group(base_path('routes/apipub.php'));
|
||||
},
|
||||
)
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
// '*' trusts all proxies, required for correct IP/HTTPS detection behind AWS ALB/Vapor
|
||||
$middleware->trustProxies(at: '*');
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
$middleware->web(append: [
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
]);
|
||||
|
||||
$app->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
$middleware->api(append: [
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
]);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
$middleware->api(prepend: [
|
||||
'throttle:300,1',
|
||||
]);
|
||||
|
||||
return $app;
|
||||
$middleware->validateCsrfTokens(except: [
|
||||
'move-order/api/move',
|
||||
]);
|
||||
|
||||
$middleware->alias([
|
||||
'valid.token' => \App\Http\Middleware\ValidateToken::class,
|
||||
'token.check' => \App\Http\Middleware\TokenCheckerMiddleware::class,
|
||||
'auth.check' => \App\Http\Middleware\CheckAuthorizationMiddleware::class,
|
||||
'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class,
|
||||
'storage.invoice.check.bytransaction' => \App\Http\Middleware\CheckForStorageInvoiceByTransactionId::class,
|
||||
'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class,
|
||||
'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class,
|
||||
'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class,
|
||||
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class,
|
||||
]);
|
||||
|
||||
$middleware->appendToGroup('apipub', [
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\LogRequestPathMiddleware::class,
|
||||
]);
|
||||
|
||||
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
$exceptions->render(function (AuthenticationException $e, $request) {
|
||||
if ($request->expectsJson()) {
|
||||
return (new ApiResponseObject('Authentication', 'To keep your account secure, we need to re-validate it.', HttpStatus::ACCESS_UNAUTHORISED))->handler();
|
||||
}
|
||||
});
|
||||
|
||||
// Don't flash these inputs
|
||||
$exceptions->dontFlash([
|
||||
'password',
|
||||
'password_confirmation',
|
||||
]);
|
||||
|
||||
// $exceptions->render(function (MaintenanceModeException $e, $request) {
|
||||
// return response()->view('pages.errors.maintenance');
|
||||
// });
|
||||
})
|
||||
->withCommands([
|
||||
__DIR__ . '/../app/Console/Commands',
|
||||
__DIR__ . '/../app/Console/Commands/V2',
|
||||
])
|
||||
->withSchedule(function (Schedule $schedule) {
|
||||
//Commands Version 2: Laravel Vapor with AWS
|
||||
$isEnabled = env('COMMANDS_V2_ENABLED', false);
|
||||
if ($isEnabled) {
|
||||
// $schedule->command('dummy-command')
|
||||
// ->everyFiveMinutes()
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('housekeeping-s3-files-command')
|
||||
->dailyAt('01:00')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('password-reset-token-expriration-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('new-user-registration-expire-check-command')
|
||||
->everySixHours()
|
||||
->withoutOverlapping();
|
||||
|
||||
if (env('APP_ENV') === 'production') {
|
||||
$schedule->command('curl-vt-command')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
// $schedule->command('curl-yd-order-list-command')
|
||||
// ->cron('0 9-18/3 * * *')
|
||||
// ->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-yd-by-traking-no-data-command')
|
||||
->cron('0 8,11,14,17 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-yd-portal-data-command')
|
||||
->cron('0 9,12,15,18 * * *') //->cron('0 9-18/3 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('fix-packinglist-command')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('fix-duplicate-container-reference-command')
|
||||
->cron('0 1 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('invoice-generate-command')
|
||||
// ->hourly()
|
||||
->cron('0 0-8,10-11,13-14,16-17,19-23 * * *')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('billplz-failed-callback-fix-command')
|
||||
->hourly()
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('check-storage-invoices-group-transactions-command')
|
||||
->dailyAt('0:01')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('permits-reminder-send-command')
|
||||
->dailyAt('09:30')
|
||||
->withoutOverlapping();
|
||||
|
||||
$schedule->command('process-delayed-jobs-command')
|
||||
->everyFiveMinutes()
|
||||
->withoutOverlapping();
|
||||
} elseif (env('APP_ENV') === 'development') {
|
||||
$schedule->command('process-delayed-jobs-command')
|
||||
->everyTwoHours()
|
||||
->withoutOverlapping();
|
||||
}
|
||||
}
|
||||
//Commands Version 1: Before AWS
|
||||
else {
|
||||
$schedule->command('command:curlVTCommand')
|
||||
->cron('0 8 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/curlvt.log');
|
||||
|
||||
$schedule->command('command:curlYdOrderListCommand')
|
||||
->cron('0 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/curlyd.log');
|
||||
|
||||
$schedule->command('fix-packinglist')
|
||||
->cron('30 9-18/3 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/fix_packinglist.log');
|
||||
|
||||
// $schedule->command('command:curlYdOrderListCommand')
|
||||
// ->cron('0 9 * * *')
|
||||
// ->withoutOverlapping()
|
||||
// ->appendOutputTo(storage_path().'/logs/departure_email.log');
|
||||
|
||||
$schedule->command('fix-duplicate-container-reference')
|
||||
->cron('0 1 * * *')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/fix_duplicate_container_reference.log');
|
||||
|
||||
$schedule->command('invoice:generate')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/auto_generate_invoice.log');
|
||||
|
||||
$schedule->command('billplz-failed-callback:fix')
|
||||
->hourly()
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/fix_failed_callback_from_billplz.log');
|
||||
|
||||
$schedule->command('check-storage-invoices-group-transactions')
|
||||
->dailyAt('0:01')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/check_storage_invoices.log');
|
||||
|
||||
$schedule->command('permitsReminder:send')
|
||||
->dailyAt('09:30')
|
||||
->withoutOverlapping()
|
||||
->appendOutputTo(storage_path() . '/logs/permits-reminder-send.log');
|
||||
}
|
||||
})
|
||||
->create();
|
||||
|
||||
+27
-26
@@ -2,38 +2,42 @@
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"keywords": [
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.3",
|
||||
"ext-fileinfo": "^7.3",
|
||||
"php": "^8.3",
|
||||
"ext-fileinfo": "*",
|
||||
"ext-json": "*",
|
||||
"barryvdh/laravel-dompdf": "^0.9.0",
|
||||
"barryvdh/laravel-dompdf": "^3.0",
|
||||
"carlos-meneses/laravel-mpdf": "^2.1",
|
||||
"doctrine/dbal": "^3.1",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "^8.40",
|
||||
"laravel/tinker": "^2.5",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"intervention/image": "^3.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"laravel/vapor-cli": "^1.60",
|
||||
"laravel/vapor-core": "^2.33",
|
||||
"league/flysystem-aws-s3-v3": "^3.0",
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"maxbanton/cwh": "^2.0",
|
||||
"rinvex/countries": "^6.1",
|
||||
"spatie/laravel-activitylog": "^3.14",
|
||||
"spatie/laravel-permission": "^4.2",
|
||||
"staudenmeir/eloquent-has-many-deep": "^1.7",
|
||||
"tymon/jwt-auth": "^1.0"
|
||||
"phpnexus/cwh": "^3.0",
|
||||
"rinvex/countries": "^9.0",
|
||||
"spatie/laravel-activitylog": "^4.8",
|
||||
"spatie/laravel-permission": "^6.0",
|
||||
"staudenmeir/eloquent-has-many-deep": "^1.19",
|
||||
"symfony/http-client": "^7.4",
|
||||
"symfony/mailgun-mailer": "^7.4",
|
||||
"tymon/jwt-auth": "^2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"facade/ignition": "^2.5",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/sail": "^1.0.1",
|
||||
"mockery/mockery": "^1.4.2",
|
||||
"nunomaduro/collision": "^5.0",
|
||||
"phpunit/phpunit": "^9.3.3"
|
||||
"spatie/laravel-ignition": "^3.0",
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/sail": "^1.26",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.0",
|
||||
"phpunit/phpunit": "^11.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -67,10 +71,7 @@
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"audit": {
|
||||
"block-insecure": false
|
||||
}
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
|
||||
+1
-2
@@ -173,7 +173,6 @@ return [
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
|
||||
// Third Parties
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
@@ -232,7 +231,7 @@ return [
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||
'PDF' => Barryvdh\DomPDF\Facade\Pdf::class,
|
||||
'MPDF' => Mccarlosen\LaravelMpdf\Facades\LaravelMpdf::class,
|
||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||
],
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
'paths' => ['api/*', 'public/api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
@@ -29,6 +29,6 @@ return [
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
'supports_credentials' => false, //cief todo: 137
|
||||
|
||||
];
|
||||
|
||||
@@ -13,7 +13,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DRIVER', 'local'),
|
||||
'default' => env('FILESYSTEM_DISK', env('FILESYSTEM_DRIVER', 'local')),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -58,6 +58,7 @@ return [
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
@@ -245,6 +245,30 @@ return [
|
||||
'level' => 'debug',
|
||||
'groupNamePrefix' => env('CLOUDWATCH_LOGGROUP_PREFIX'),
|
||||
],
|
||||
|
||||
'request_path' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel_request_path.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
|
||||
'request_path_vapor' => [
|
||||
'driver' => 'custom',
|
||||
'via' => \App\Logging\CloudWatchLoggerFactory::class,
|
||||
'formatter' => Monolog\Formatter\JsonFormatter::class,
|
||||
'cloudwatch_stream_name' => 'request_path_vapor',
|
||||
'sdk' => [
|
||||
'region' => env('AWS_MY_REGION'),
|
||||
'version' => 'latest',
|
||||
'credentials' => [
|
||||
'key' => env('AWS_CW_ACCESS'),
|
||||
'secret' => env('AWS_CW_SECRET')
|
||||
]
|
||||
],
|
||||
'retention' => env('APP_ENV') === 'production' ? 90 : 14,
|
||||
'level' => 'debug',
|
||||
'groupNamePrefix' => env('CLOUDWATCH_LOGGROUP_PREFIX'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -8,25 +8,57 @@ class AddIsWaivedToTransactionsLogsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('transaction_logs', function (Blueprint $table) {
|
||||
$table->boolean('is_waived')->nullable()->after('status')->default(false);
|
||||
if (!Schema::hasTable('transaction_logs')) {
|
||||
// Create the table from scratch
|
||||
Schema::create('transaction_logs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->bigInteger('transaction_id');
|
||||
$table->string('owner_type', 250);
|
||||
$table->unsignedBigInteger('owner_id');
|
||||
$table->string('type')->default('1');
|
||||
$table->unsignedBigInteger('issuer');
|
||||
$table->unsignedBigInteger('receiver');
|
||||
$table->unsignedBigInteger('recipient_bank_account_id');
|
||||
$table->string('payment_method')->nullable();
|
||||
$table->string('payment_reference')->nullable();
|
||||
$table->string('bill_no');
|
||||
$table->decimal('amount', 25, 5)->default(0);
|
||||
$table->decimal('original_amount', 25, 5)->default(0);
|
||||
$table->unsignedBigInteger('currency_id');
|
||||
$table->unsignedBigInteger('original_currency_id');
|
||||
$table->decimal('currency_rate', 14, 5)->default(0);
|
||||
$table->decimal('tax', 14, 5)->default(0);
|
||||
$table->decimal('service_charge', 14, 5)->default(0);
|
||||
$table->timestamp('expires_on')->nullable();
|
||||
$table->integer('status')->default(0);
|
||||
$table->boolean('is_waived')->default(false);
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
});
|
||||
} else {
|
||||
// Add the column if the table exists
|
||||
Schema::table('transaction_logs', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('transaction_logs', 'is_waived')) {
|
||||
$table->boolean('is_waived')->nullable()->after('status')->default(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (Schema::hasTable('transaction_logs')) {
|
||||
Schema::table('transaction_logs', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('transaction_logs', 'is_waived')) {
|
||||
$table->dropColumn('is_waived');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM laravelphp/vapor:php74
|
||||
FROM laravelphp/vapor:php83
|
||||
|
||||
COPY . /var/task
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM php:7.4-fpm
|
||||
FROM php:8.3-fpm
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
@@ -18,10 +18,10 @@ RUN apt-get update && apt-get install -y \
|
||||
&& docker-php-ext-install zip \
|
||||
&& docker-php-ext-install bcmath
|
||||
|
||||
COPY --from=composer:1.9.3 /usr/bin/composer /usr/bin/composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
#NODEJS & NPM
|
||||
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
|
||||
RUN apt-get -y install nodejs
|
||||
|
||||
RUN chown -R www-data:www-data /var/www
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
version: '3'
|
||||
|
||||
networks:
|
||||
shipping-portal-staging:
|
||||
shipping-portal-development:
|
||||
|
||||
services:
|
||||
#################################################################
|
||||
nginx:
|
||||
image: nginx:stable-alpine
|
||||
container_name: shipping-portal-ngnix
|
||||
container_name: shipping-portal-2-ngnix
|
||||
ports:
|
||||
- "8081:80"
|
||||
volumes:
|
||||
@@ -17,11 +17,11 @@ services:
|
||||
- php
|
||||
- mysql
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
- shipping-portal-development
|
||||
#################################################################
|
||||
mysql:
|
||||
image: mysql:5.7.29
|
||||
container_name: shipping-portal-mysql
|
||||
container_name: shipping-portal-2-mysql
|
||||
restart: unless-stopped
|
||||
tty: true
|
||||
ports:
|
||||
@@ -36,19 +36,19 @@ services:
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
- shipping-portal-development
|
||||
#################################################################
|
||||
php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: shipping-portal-php
|
||||
container_name: shipping-portal-2-php
|
||||
volumes:
|
||||
- ../:/var/www/html
|
||||
ports:
|
||||
- "9001:9000"
|
||||
networks:
|
||||
- shipping-portal-staging
|
||||
- shipping-portal-development
|
||||
#################################################################
|
||||
|
||||
volumes:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<!-- <server name="DB_CONNECTION" value="sqlite"/> -->
|
||||
<!-- <server name="DB_DATABASE" value=":memory:"/> -->
|
||||
<!--
|
||||
<server name="DB_CONNECTION" value="mysql"/>
|
||||
<server name="DB_HOST" value="172.18.0.3"/>
|
||||
<server name="DB_PORT" value="3306"/>
|
||||
<server name="DB_DATABASE" value="ci_test"/>
|
||||
<server name="DB_USERNAME" value="ci"/>
|
||||
<server name="DB_PASSWORD" value="ci"/>
|
||||
-->
|
||||
<server name="MAIL_MAILER" value="array"/>
|
||||
<server name="QUEUE_CONNECTION" value="sync"/>
|
||||
<server name="SESSION_DRIVER" value="array"/>
|
||||
<server name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user