mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-25 15:34:09 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b30357568 | |||
| 034e9da69e |
@@ -57,15 +57,3 @@ MIX_EXCHANGE_URL="${EXCHANGE_URL}"
|
|||||||
YD_API_CODE=''
|
YD_API_CODE=''
|
||||||
|
|
||||||
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
JWT_SECRET=Btj63iMEleEaww6Bb2IBECkxWn7YHPhhPFluAkg9DfcQik0qDRy6QW75ABGmPT2h
|
||||||
|
|
||||||
PERFEXCRM_BASE_URL=""
|
|
||||||
PERFEXCRM_API_KEY=""
|
|
||||||
PERFEXCRM_IS_ENABLED="false"
|
|
||||||
|
|
||||||
WEPOST_BASE_URL=https://wepost-uat.90warehouse.com/api/router
|
|
||||||
WEPOST_CLIENT_ID=1234
|
|
||||||
WEPOST_CLIENT_SECRET=cief-secret-temp
|
|
||||||
WEPOST_IS_ENABLED=false
|
|
||||||
|
|
||||||
STORAGE_FEE_LAUNCH_DATE="2023-12-11 00:00:00"
|
|
||||||
SST_START_DATE="2024-04-01 00:00:00"
|
|
||||||
|
|||||||
+51
-22
@@ -26,7 +26,7 @@ before_script:
|
|||||||
- apt-get install -y libgd-dev
|
- apt-get install -y libgd-dev
|
||||||
- apt-get install -y libgd-dev
|
- apt-get install -y libgd-dev
|
||||||
|
|
||||||
# Install PDO MySQL extension
|
# Install PDO MySQL extension
|
||||||
- docker-php-ext-install pdo_mysql
|
- docker-php-ext-install pdo_mysql
|
||||||
|
|
||||||
#install php dependencies
|
#install php dependencies
|
||||||
@@ -70,8 +70,8 @@ npm:
|
|||||||
#building assets
|
#building assets
|
||||||
building_assets:
|
building_assets:
|
||||||
stage: building_assets
|
stage: building_assets
|
||||||
# dependencies:
|
# dependencies:
|
||||||
# - npm
|
# - npm
|
||||||
script:
|
script:
|
||||||
- npm install # Install npm dependencies
|
- npm install # Install npm dependencies
|
||||||
- gulp build # Build assets
|
- gulp build # Build assets
|
||||||
@@ -84,8 +84,8 @@ database:
|
|||||||
services:
|
services:
|
||||||
- name: mysql:8.0
|
- name: mysql:8.0
|
||||||
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
#dependencies:
|
#dependencies:
|
||||||
# - composer_php
|
# - composer_php
|
||||||
script:
|
script:
|
||||||
- composer install
|
- composer install
|
||||||
- cp .env.example .env
|
- cp .env.example .env
|
||||||
@@ -95,25 +95,54 @@ database:
|
|||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
#mysql
|
#unit test
|
||||||
#unit_test:
|
unit_test:
|
||||||
# stage: unit_test
|
stage: unit_test
|
||||||
# services:
|
services:
|
||||||
# - name: mysql:8.0
|
- name: mysql:8.0
|
||||||
# command: [ "--default-authentication-plugin=mysql_native_password" ]
|
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
#dependencies:
|
#dependencies:
|
||||||
# - database
|
# - database
|
||||||
# script:
|
script:
|
||||||
# - npm install # Install npm dependencies
|
- npm install # Install npm dependencies
|
||||||
# - gulp build # Build assets
|
- gulp build # Build assets
|
||||||
# - composer install
|
- composer install
|
||||||
# - cp .env.example .env
|
- cp .env.example .env
|
||||||
# - php artisan key:generate
|
- php artisan key:generate
|
||||||
# - php artisan migrate:fresh
|
- php artisan migrate:fresh
|
||||||
# - php artisan db:seed
|
- php artisan db:seed
|
||||||
# - php artisan test
|
- php artisan test
|
||||||
# rules:
|
rules:
|
||||||
# - if: '$CI_COMMIT_BRANCH =~ /.*/'
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#acceptance tests
|
||||||
|
acceptance_test:
|
||||||
|
stage: acceptance_test
|
||||||
|
services:
|
||||||
|
- name: mysql:8.0
|
||||||
|
command: [ "--default-authentication-plugin=mysql_native_password" ]
|
||||||
|
- selenium/standalone-chrome:latest
|
||||||
|
#dependencies:
|
||||||
|
# - database
|
||||||
|
script:
|
||||||
|
- npm install # Install npm dependencies
|
||||||
|
- gulp build # Build assets
|
||||||
|
- composer install
|
||||||
|
- cp .env.example .env
|
||||||
|
- php artisan key:generate
|
||||||
|
- php artisan migrate:fresh
|
||||||
|
- php artisan db:seed
|
||||||
|
- php artisan serve &
|
||||||
|
- vendor/bin/codecept run
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
paths:
|
||||||
|
- tests/_output
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH =~ /.*/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
final class ConnectionErrorException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
|
|
||||||
Log::error($message. ": ". $exceptionMessage);
|
|
||||||
if($payload){
|
|
||||||
Log::error('Payload: '.$payload);
|
|
||||||
}
|
|
||||||
if($exceptionTrace){
|
|
||||||
Log::error($exceptionTrace);
|
|
||||||
}
|
|
||||||
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
|
|
||||||
HttpStatus::SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Exceptions;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
|
|
||||||
final class JobResourceNotFoundException extends ServiceApiException {
|
|
||||||
public function __construct(?string $message = null) {
|
|
||||||
parent::__construct($message ?? 'Unable to find the requested resource', HttpStatus::RESOURCE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Abstracts;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\ErrorException;
|
|
||||||
use App\Classes\Exceptions\InternalServerErrorException;
|
|
||||||
use App\Classes\ValueObjects\Constants\Notifications;
|
|
||||||
use App\Classes\ValueObjects\Constants\HttpStatus;
|
|
||||||
use App\Classes\ValueObjects\Response\ApiResponseObject;
|
|
||||||
use ErrorException as GeneralExceptions;
|
|
||||||
use TypeError;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
abstract class Abstract2ControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
abstract protected function notification(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationTitle():string {
|
|
||||||
return $this->notification()['title'] ? $this->notification()['title']: Notifications::UNDEFINED['title'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getNotificationMessage():string {
|
|
||||||
return $this->notification()['message'] ? $this->notification()['message']: Notifications::UNDEFINED['message'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
abstract protected function logic(Request $request) : BinaryFileResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return BinaryFileResponse
|
|
||||||
*/
|
|
||||||
public function execute(Request $request) : BinaryFileResponse {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
$response = $this->logic($request);
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
|
||||||
abort(404, $exception->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array|null $data
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function response(?array $data = []) : JsonResponse {
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' Successful',
|
|
||||||
$this->getNotificationMessage(),
|
|
||||||
HttpStatus::OK_WITH_MESSAGE, $data))->handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param JsonResource $resource
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function resourceResponse(JsonResource $resource){
|
|
||||||
return $this->response(['data' => $resource]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function collectionResponse(ResourceCollection $collection){
|
|
||||||
return $this->response(json_decode($collection->response()->getContent(), true));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,6 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
abstract class AbstractControllerLogic
|
abstract class AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -64,28 +62,9 @@ abstract class AbstractControllerLogic
|
|||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
} catch (ErrorException|GeneralExceptions|TypeError $exception){
|
||||||
if ($request->has('isApiPub')) {
|
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
||||||
Log::error($exception);
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', "Server Error",
|
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
||||||
|
|
||||||
} else {
|
|
||||||
if ($exception instanceof JobResourceNotFoundException) {
|
|
||||||
Log::channel('vue_polling')->info(sprintf(
|
|
||||||
"Uncaught exception '%s' with message '%s' in %s:%d",
|
|
||||||
get_class($exception),
|
|
||||||
$exception->getMessage(),
|
|
||||||
$exception->getTrace()[0]['file'],
|
|
||||||
$exception->getTrace()[0]['line']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Log::error($exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (new ApiResponseObject($this->getNotificationTitle().' failed', $exception->getMessage(),
|
|
||||||
!in_array($exception->getCode(), [0, 42000]) ? $exception->getCode() : HttpStatus::SERVER_ERROR))->handler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use App\Classes\General\Interfaces\DataTransferObject;
|
|||||||
abstract class AbstractRule
|
abstract class AbstractRule
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function authorized($object): bool;
|
abstract protected function authorized(): bool;
|
||||||
|
|
||||||
abstract protected function validators($object): bool;
|
abstract protected function validators($object): bool;
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ abstract class AbstractRule
|
|||||||
*/
|
*/
|
||||||
public function passes(?DataTransferObject $object = null): bool {
|
public function passes(?DataTransferObject $object = null): bool {
|
||||||
try {
|
try {
|
||||||
if(!$this->authorized($object)){
|
if(!$this->authorized()){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validators($object);
|
$this->validators($object);
|
||||||
@@ -36,11 +36,11 @@ abstract class AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch(AccessForbiddenException $exception){
|
} catch(AccessForbiddenException $exception){
|
||||||
throw new AccessForbiddenException('You don\'t have permission to perform this action');
|
throw new AccessForbiddenException('You don\'t have permission to preform this action');
|
||||||
} catch(\Exception $exception){
|
} catch(\Exception $exception){
|
||||||
throw new RequestValidationException($exception->getMessage());
|
throw new RequestValidationException($exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,6 @@ namespace App\Classes\General\Eloquent;
|
|||||||
use App\Classes\Exceptions\ResourceNotFoundException;
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Classes\Exceptions\JobResourceNotFoundException;
|
|
||||||
|
|
||||||
|
|
||||||
abstract class AbstractFetchRecord extends AbstractGetRecord
|
abstract class AbstractFetchRecord extends AbstractGetRecord
|
||||||
{
|
{
|
||||||
@@ -28,18 +26,12 @@ abstract class AbstractFetchRecord extends AbstractGetRecord
|
|||||||
* @return Model
|
* @return Model
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []): Model {
|
public function getResults(Builder $query): Model {
|
||||||
if(!$query->exists()){
|
if(!$query->exists()){
|
||||||
$table = $query->getModel()->getTable();
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
||||||
if($table ==='job_results'){
|
|
||||||
throw new JobResourceNotFoundException('Unable to find any job based on the criteria provided');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->first();
|
return $query->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -50,9 +50,9 @@ abstract class AbstractGetRecord
|
|||||||
* @param array $filters
|
* @param array $filters
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handler(array $filters, array $params = []){
|
public function handler(array $filters){
|
||||||
$this->filters = collect($filters);
|
$this->filters = collect($filters);
|
||||||
return $this->getResults($this->applyFiltersToQuery(), $params);
|
return $this->getResults($this->applyFiltersToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +65,6 @@ abstract class AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
abstract function getResults(Builder $query, array $params = []);
|
abstract function getResults(Builder $query);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,11 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws MalformedRequestException
|
* @throws MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(array $filters = [], array $param = []){
|
public function execute(array $filters = []){
|
||||||
|
|
||||||
try{
|
try{
|
||||||
return $this->handler($filters, $param);
|
|
||||||
|
return $this->handler($filters);
|
||||||
|
|
||||||
} catch (QueryException $exception){
|
} catch (QueryException $exception){
|
||||||
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
throw new MalformedRequestException('Unable to fetch the list of records due to unexpected error');
|
||||||
@@ -31,7 +32,7 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
* @param Builder $query
|
* @param Builder $query
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getResults(Builder $query, array $param = []) {
|
public function getResults(Builder $query) {
|
||||||
$filters = $this->getDecorationFilters();
|
$filters = $this->getDecorationFilters();
|
||||||
|
|
||||||
if($filters->has('order_by')){
|
if($filters->has('order_by')){
|
||||||
@@ -43,12 +44,8 @@ abstract class AbstractListRecord extends AbstractGetRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dd($query->toSql());
|
//dd($query->toSql());
|
||||||
if(!empty($param)){
|
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page'), ['*'], 'page', $param['page']) : $query->get(); //page data from query parameters e.g ?page=1
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return $filters->has('per_page') ? $query->paginate($filters->get('per_page')) : $query->get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class AmountExceed implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('amount', '>', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class AmountShort implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('amount', '<', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class BillNo implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('bill_no', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CompanySegmentsIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
|
||||||
$module->whereHas('connections', function ($connection) use ($value) {
|
|
||||||
$connection->whereHas('connectionSegments', function ($segment) use ($value) {
|
|
||||||
$segment->whereIn('segment_id', $value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedAfterOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '>=', $startDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedBefore implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('created_at', '<', Carbon::parse($value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CreatedBeforeOrEqual implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$table = $builder->getModel()->getTable();
|
|
||||||
$endDate = Carbon::createFromFormat('d-m-Y', $value)->endOfDay();
|
|
||||||
return $builder->where("{$table}.created_at", '<=', $endDate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class DoesNotHaveGroups implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereDoesntHave('groups');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class DoesNotHavePaymentStatusIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
|
||||||
$query->where('type', TransactionType::PAYMENT)->whereIn('status', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ class DoesNotHaveTransactionType implements Filter
|
|||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
|
||||||
$query->where('type', $value)->whereIn('status', [0,1,2,3,5]);
|
$query->where('type', $value);
|
||||||
})->whereHas('containers', function ($query){
|
})->whereHas('containers', function ($query){
|
||||||
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class EmailLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('email', 'LIKE', '%'.$value.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HasQuestionnaireGroupIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('question.questionnaire', function (Builder $query) use ($value) {
|
|
||||||
$query->whereIn('group', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class HavePaymentStatusNotIn implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('transactions', function (Builder $query) use($value) {
|
|
||||||
$query->where('type', TransactionType::PAYMENT)->whereNotIn('status', $value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class IdNext implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('id', '>', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class JobId implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('job_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class MarkingIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereHas('companyModules', function ($module) use ($value) {
|
|
||||||
$module->whereHas('connections', function ($connection) use ($value) {
|
|
||||||
$connection->whereIn('invitee_reference', $value);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class NextMainQuestion implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('next_main_question', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByIdDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('id', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class OrderByUpdatedAtDesc implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->orderBy('updated_at', 'desc');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class OwnerId implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->where('owner_id', $value);
|
||||||
return $builder->where("{$table}.owner_id", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,7 @@ class OwnerType implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->where('owner_type', $value);
|
||||||
return $builder->where("{$table}.owner_type", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-32
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
||||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
|
||||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->select('packing_lists.*')->join('transactions', function($join){
|
|
||||||
$join->on('transactions.owner_id', '=', 'packing_lists.id');
|
|
||||||
$join->where('transactions.owner_type', '=', PackingList::class);
|
|
||||||
$join->where('transactions.status', '=', ApprovalStatus::APPROVED);
|
|
||||||
$join->whereRaw('(transactions.type <> 16 OR transactions.id = (
|
|
||||||
SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1
|
|
||||||
))');
|
|
||||||
})->orderBy('transactions.updated_at', 'DESC');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PaymentMethod implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('payment_method', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PaymentMethodNotIn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotIn('payment_method', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class PostcodeLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('postcode', 'LIKE', '%'.$value.'%');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('question_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionNumber implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('question_number', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class QuestionnaireSetId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('questionnaire_set_id', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class RequestSignature implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('request_signature', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ResultNotNull implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->whereNotNull('result');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class ShortUrl implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('short_url', $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@ class StatusIn implements Filter
|
|||||||
*/
|
*/
|
||||||
public static function apply(Builder $builder, $value)
|
public static function apply(Builder $builder, $value)
|
||||||
{
|
{
|
||||||
$table = $builder->getModel()->getTable();
|
return $builder->whereIn('status', $value);
|
||||||
return $builder->whereIn("{$table}.status", $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class UserId implements Filter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return Builder|mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->where('user_id', $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithAgingColumn implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
$today = Carbon::now();
|
|
||||||
return $builder->select('packing_lists.*')
|
|
||||||
->addSelect(DB::raw("DATEDIFF('$today', transactions.updated_at) as days_over_duedate"))
|
|
||||||
->addSelect(DB::raw("CASE
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) <= 0 THEN 0
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 0 AND DATEDIFF('$today', transactions.updated_at) <= 30 THEN 1
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 30 AND DATEDIFF('$today', transactions.updated_at) <= 60 THEN 2
|
|
||||||
WHEN DATEDIFF('$today', transactions.updated_at) > 60 AND DATEDIFF('$today', transactions.updated_at) <= 90 THEN 3
|
|
||||||
ELSE 4
|
|
||||||
END AS due_date_number"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class WithContainersPackages implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
// Log::info('WithContainersPackages: '.$value);
|
|
||||||
// return $builder->with(['containers', 'packages']);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithOrderReferenceLike implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->join('transactions as t2', 't2.payment_reference', '=', 'transactions.bill_no')
|
|
||||||
->join('transactions as t3', 't3.id', '=', 't2.owner_id')
|
|
||||||
->join('packing_lists', 'packing_lists.id', '=', 't3.owner_id')
|
|
||||||
->join('orders', function ($join) use ($value) {
|
|
||||||
$join->on('orders.id', '=', 'packing_lists.owner_id')
|
|
||||||
->where('orders.reference', 'LIKE', '%'.$value.'%');
|
|
||||||
})
|
|
||||||
->addSelect(['transactions.*', 't2.id as paymentTransactionId', 't3.id as invoiceTransactionId', 'packing_lists.id as packingListId', 'orders.reference as orderReference']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Eloquent\Filters;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class WithTrashed implements Filter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Builder $builder
|
|
||||||
* @param $value
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function apply(Builder $builder, $value)
|
|
||||||
{
|
|
||||||
return $builder->withTrashed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Classes\General;
|
namespace App\Classes\General;
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class Helper
|
class Helper
|
||||||
{
|
{
|
||||||
@@ -25,28 +24,4 @@ class Helper
|
|||||||
return array_slice(get_class_methods($className), 1);
|
return array_slice(get_class_methods($className), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
}
|
||||||
* @param $log
|
|
||||||
*/
|
|
||||||
static function debugLogger($log){
|
|
||||||
if($log && isset($log['message'])){
|
|
||||||
$message = $log['message'];
|
|
||||||
$substring = 'No data were found';
|
|
||||||
if (isset($message)) {
|
|
||||||
if (strpos($message, $substring) !== false) {
|
|
||||||
// Log::info('Message exist');
|
|
||||||
} else {
|
|
||||||
Log::info($log['message']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ResourceCollection $collection
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
static function collectionResponse(ResourceCollection $collection){
|
|
||||||
return json_decode($collection->response()->getContent(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General\Interfaces;
|
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
||||||
|
|
||||||
interface KeyValueInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function attributes(): morphMany;
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\General;
|
|
||||||
|
|
||||||
|
|
||||||
class WePostHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $clientId
|
|
||||||
* @param string $clientSecrent
|
|
||||||
* @param string $type
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static function generateSignature(string $clientId, string $clientSecrent, string $type){
|
|
||||||
// public parameters
|
|
||||||
$timestamp = 1234; //time();
|
|
||||||
|
|
||||||
$params = [
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'type' => $type,
|
|
||||||
'timestamp' => $timestamp
|
|
||||||
];
|
|
||||||
|
|
||||||
// $businessParams = [
|
|
||||||
// 'test1' => '1',
|
|
||||||
// ];
|
|
||||||
|
|
||||||
ksort($params);
|
|
||||||
$str = '';
|
|
||||||
foreach ($params as $key => $value) {
|
|
||||||
if(is_array($value)) {
|
|
||||||
$str .= $key.json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$str .= $key. $value;
|
|
||||||
}
|
|
||||||
$str = $clientSecrent.$str.$clientSecrent;
|
|
||||||
$signature = strtoupper(md5($str));
|
|
||||||
return $signature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMLeadProcessor;
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMLead;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
@@ -30,12 +28,6 @@ class CreatePerfexCRMCustomer implements ShouldQueue
|
|||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$lead = (App()->make(FetchesPerfexCRMLead::class))->execute($this->createLeadPerfexCRMObject->getEmail());
|
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
||||||
if(!is_null($lead)){
|
|
||||||
(App()->make(UpdatesPerfexCRMLead::class))->execute($lead, $this->createLeadPerfexCRMObject->getCompanyReference());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
(App()->make(CreatePerfexCRMLeadProcessor::class))->execute($this->createLeadPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
|
|
||||||
class CreatePerfexCRMInvoice implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var Transaction $transaction*/
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMInvoice constructor.
|
|
||||||
* @param Transaction $transaction
|
|
||||||
*/
|
|
||||||
public function __construct(Transaction $transaction)
|
|
||||||
{
|
|
||||||
$this->transaction = $transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
(App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($this->transaction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,12 +4,12 @@ namespace App\Classes\Jobs;
|
|||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMTaskProcessor;
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMLead;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
|
||||||
|
|
||||||
class CreatePerfexCRMSingleTask implements ShouldQueue
|
class CreatePerfexCRMSingleTask implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
class FetchOrdersFromYDPortalJob implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -30,17 +29,12 @@ class FetchOrdersFromYDPortalJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Log::info('FetchOrdersFromYDPortalJob starts');
|
|
||||||
Log::info('FetchPackingListsFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchPackingListsFromYdPortalProcessor::class))->execute();
|
||||||
Log::info('FetchContainersFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchContainersFromYdPortalProcessor::class))->execute();
|
||||||
Log::info('FetchContainersUpdatesFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchContainersUpdatesFromYdPortalProcessor::class))->execute();
|
||||||
Log::info('FetchDeliveryUpdatesFromYdPortalProcessor starts');
|
|
||||||
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
(App()->make(FetchDeliveryUpdatesFromYdPortalProcessor::class))->execute();
|
||||||
Log::info('FetchOrdersFromYDPortalJob ends');
|
|
||||||
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
// (App()->make(FetchOrderListsFromYdPortalProcessor::class))->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
|
use App\Classes\Modules\PerfexCRM\Processors\InitializePerfexCRMProcessor;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InitialPerfexCRMObject;
|
||||||
|
|
||||||
|
class InitializePerfexCRM implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/** @var InitialPerfexCRMObject */
|
||||||
|
private $initialPerfexCRMObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InitializePerfexCRM constructor.
|
||||||
|
* @param InitialPerfexCRMObject $initialPerfexCRMObject
|
||||||
|
*/
|
||||||
|
public function __construct(InitialPerfexCRMObject $initialPerfexCRMObject)
|
||||||
|
{
|
||||||
|
$this->initialPerfexCRMObject = $initialPerfexCRMObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
(App()->make(InitializePerfexCRMProcessor::class))->execute($this->initialPerfexCRMObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PackingLists\Processors\ListPackingListsJobProcessor;
|
|
||||||
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
class ListPackingListsJob implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
public $timeout = 900;
|
|
||||||
|
|
||||||
/** @var ListGenericJobObject */
|
|
||||||
private $listGenericJobObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ListPackingListsJob constructor.
|
|
||||||
* @param ListGenericJobObject $listGenericJobObject
|
|
||||||
*/
|
|
||||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
|
||||||
{
|
|
||||||
$this->listGenericJobObject = $listGenericJobObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$rawPayload = $this->job->payload();
|
|
||||||
if(isset($rawPayload['data']['commandName'])){
|
|
||||||
$this->listGenericJobObject->setJobCommandName($rawPayload['data']['commandName']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($rawPayload['data']['command'])){
|
|
||||||
$this->listGenericJobObject->setJobCommand($rawPayload['data']['command']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = (App()->make(ListPackingListsJobProcessor::class))->execute($this->listGenericJobObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,17 +3,12 @@
|
|||||||
namespace App\Classes\Jobs;
|
namespace App\Classes\Jobs;
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\FetchPerfexCRMInvoiceProcessor;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\FetchPerfexCRMInvoiceObject;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRM implements ShouldQueue
|
class UpdatePerfexCRM implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -22,51 +17,17 @@ class UpdatePerfexCRM implements ShouldQueue
|
|||||||
/** @var UpdatePerfexCRMObject */
|
/** @var UpdatePerfexCRMObject */
|
||||||
private $updatePerfexCRMObject;
|
private $updatePerfexCRMObject;
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/** @var bool|null */
|
|
||||||
private $shouldCreateInvoice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdatePerfexCRM constructor.
|
* UpdatePerfexCRM constructor.
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||||
* @param Transaction $transaction
|
|
||||||
* @param bool|null $shouldCreateInvoice
|
|
||||||
*/
|
*/
|
||||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false)
|
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||||
{
|
{
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||||
$this->transaction = $transaction;
|
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
//To use invoice as a reference to decide whether more tasks should be created
|
(App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||||
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice());
|
|
||||||
|
|
||||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
|
||||||
if($this->transaction != null && $this->shouldCreateInvoice){
|
|
||||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
|
||||||
$result->projectId,
|
|
||||||
$this->transaction,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceOject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getInvoiceIdOrCreateInvoice(){
|
|
||||||
if($this->transaction != null){
|
|
||||||
$fetchPerfexCRMInvoiceObject = new FetchPerfexCRMInvoiceObject(
|
|
||||||
$this->updatePerfexCRMObject->getContactEmail(),
|
|
||||||
$this->transaction
|
|
||||||
);
|
|
||||||
$invoiceId = (App()->make(FetchPerfexCRMInvoiceProcessor::class))->execute($fetchPerfexCRMInvoiceObject);
|
|
||||||
return $invoiceId;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\Processors\CreatePerfexCRMInvoiceProcessor;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMInvoicePayment;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMCustomer;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMInvoice;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\FetchesPerfexCRMProject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\Services\UpdatesPerfexCRMInvoice;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
|
|
||||||
use App\Classes\ValueObjects\Constants\PerfexCRMInvoiceStatus;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
use App\Classes\General\Helper;
|
|
||||||
|
|
||||||
class UpdatePerfexCRMInvoice implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMInvoiceObject */
|
|
||||||
private $updatePerfexCRMInvoiceObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreatePerfexCRMSingleTask constructor.
|
|
||||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
|
||||||
*/
|
|
||||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
|
||||||
{
|
|
||||||
$this->updatePerfexCRMInvoiceObject = $updatePerfexCRMInvoiceObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
//get the client id
|
|
||||||
$customer = (App()->make(FetchesPerfexCRMCustomer::class))->execute($this->updatePerfexCRMInvoiceObject->getEmail());
|
|
||||||
$transaction = $this->updatePerfexCRMInvoiceObject->getTransaction();
|
|
||||||
|
|
||||||
//get the invoice id
|
|
||||||
$invoiceId = 0;
|
|
||||||
$invoiceStatus = 0;
|
|
||||||
$invoice = (App()->make(FetchesPerfexCRMInvoice::class))->execute($customer->userid,"INV-", $transaction->owner->bill_no);
|
|
||||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice debug bill_no: ' . $transaction->owner->bill_no . ', Project Id: ' . $this->updatePerfexCRMInvoiceObject->getProjectId());
|
|
||||||
|
|
||||||
if(is_null($invoice)){
|
|
||||||
$result = (App()->make(CreatePerfexCRMInvoiceProcessor::class))->execute($transaction->owner, $this->updatePerfexCRMInvoiceObject->getIsPaid());
|
|
||||||
if ($result) {
|
|
||||||
$invoiceId = $result->payload['id'];
|
|
||||||
} else {
|
|
||||||
// Log::error(json_encode('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed'));
|
|
||||||
Log::channel('perfex_crm')->info('UpdatePerfexCRMInvoice CreatePerfexCRMInvoiceProcessor failed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$invoiceId = $invoice->id;
|
|
||||||
$invoiceStatus = $invoice->status;
|
|
||||||
|
|
||||||
//This only run when invoice already exist and the invoice does not have a PAID status
|
|
||||||
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
|
||||||
//update invoice
|
|
||||||
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $this->updatePerfexCRMInvoiceObject->getProjectId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//create invoice payment
|
|
||||||
if($invoiceId != 0 && $invoiceStatus != PerfexCRMInvoiceStatus::PAID){
|
|
||||||
|
|
||||||
$date = Carbon::parse($transaction->created_at)->format('Y-m-d');
|
|
||||||
|
|
||||||
$invoicePaymentPerfexCRMObject = new InvoicePaymentPerfexCRMObject(
|
|
||||||
$invoiceId,
|
|
||||||
"$transaction->amount",
|
|
||||||
$date,
|
|
||||||
1,
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
);
|
|
||||||
(App()->make(CreatesPerfexCRMInvoicePayment::class))->execute($invoicePaymentPerfexCRMObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delay($delay)
|
|
||||||
{
|
|
||||||
// Add delay in seconds to the job
|
|
||||||
$this->delay = $delay;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Jobs;
|
|
||||||
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
|
||||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
|
||||||
use App\Models\PackingList;
|
|
||||||
use App\Models\Transaction;
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
|
|
||||||
class UpdatePerfexCRMPrelude implements ShouldQueue
|
|
||||||
{
|
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $packingList;
|
|
||||||
|
|
||||||
/** @var */
|
|
||||||
private $transaction;
|
|
||||||
|
|
||||||
/** @var UpdatePerfexCRMObject */
|
|
||||||
private $updatePerfexCRMObject;
|
|
||||||
|
|
||||||
/** @var bool|null */
|
|
||||||
private $shouldCreateInvoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdatePerfexCRMPrelude constructor.
|
|
||||||
* @param $packingList
|
|
||||||
* @param Transaction $transaction
|
|
||||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
|
||||||
* @param bool|null $shouldCreateInvoice
|
|
||||||
*/
|
|
||||||
public function __construct($packingList, $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
|
||||||
{
|
|
||||||
$this->packingList = $packingList;
|
|
||||||
$this->transaction = $transaction;
|
|
||||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
|
||||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
if(is_null($this->packingList)){
|
|
||||||
$this->packingList = $this->transaction->owner->owner;
|
|
||||||
}
|
|
||||||
$amount = 0.00;
|
|
||||||
if(!is_null($this->transaction)){
|
|
||||||
$amount = $this->transaction->amount;
|
|
||||||
}
|
|
||||||
$data = [
|
|
||||||
'amount' => number_format($amount, 2, '.', ''),
|
|
||||||
'link_order' => config('app.url').'/order/show/'.$this->packingList->owner->reference,
|
|
||||||
'link_autocount_or' => 'https://docs.google.com/spreadsheets/d/1Q3rJBGQ9Bo04HZp5WR9zbLp7pIW2kfDYsabxG7JON-4/edit#gid=2013983170',
|
|
||||||
'link_perfex' => 'https://perfex.cief-malaysia.com/admin/projects/view/89',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
|
||||||
$this->updatePerfexCRMObject->setTasks($result);
|
|
||||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
function replacePlaceholders($template, $data, $prefix = '')
|
|
||||||
{
|
|
||||||
foreach ($template as $key => $value) {
|
|
||||||
foreach ($data as $dataKey => $dataValue) {
|
|
||||||
if (is_array($dataValue)) {
|
|
||||||
$template[$key] = $this->replacePlaceholders($template[$key], $dataValue, $dataKey);
|
|
||||||
} else {
|
|
||||||
if ($prefix != '') {
|
|
||||||
$template[$key] = str_replace('{' .$prefix. "." .$dataKey . '}', $dataValue, $template[$key]);
|
|
||||||
} else {
|
|
||||||
$template[$key] = str_replace('{' . $dataKey . '}', $dataValue, $template[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -28,8 +28,7 @@ use App\Classes\ValueObjects\Constants\CompanyType;
|
|||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
||||||
|
|
||||||
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
use App\Classes\Jobs\CreatePerfexCRMCustomer;
|
||||||
use App\Classes\Modules\Accounts\Processors\RegisterOnExchangeProcessor;
|
|
||||||
use App\Classes\Modules\Companies\Services\ConnectCompanyModuleToExchangeCompany;
|
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -37,8 +36,6 @@ use App\Models\User;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class CreateCustomerLogic extends AbstractControllerLogic
|
class CreateCustomerLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -90,12 +87,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
/** @var CreatePerfexCRMLeadProcessor */
|
/** @var CreatePerfexCRMLeadProcessor */
|
||||||
private $createPerfexCRMLeadProcessor;
|
private $createPerfexCRMLeadProcessor;
|
||||||
|
|
||||||
/** @var RegisterOnExchangeProcessor */
|
|
||||||
private $registerOnExchangeProcessor;
|
|
||||||
|
|
||||||
/** @var ConnectCompanyModuleToExchangeCompany */
|
|
||||||
private $connectCompanyModuleToExchangeCompany;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateCustomerLogic constructor.
|
* CreateCustomerLogic constructor.
|
||||||
* @param CreateUserProcessor $createUserProcessor
|
* @param CreateUserProcessor $createUserProcessor
|
||||||
@@ -110,10 +101,8 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
* @param GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor
|
||||||
* @param FetchesCompanyModule $fetchesCompanyModule
|
* @param FetchesCompanyModule $fetchesCompanyModule
|
||||||
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
* @param CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor
|
||||||
* @param RegisterOnExchangeProcessor $registerOnExchangeProcessor
|
|
||||||
* @param ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany
|
|
||||||
*/
|
*/
|
||||||
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor, RegisterOnExchangeProcessor $registerOnExchangeProcessor, ConnectCompanyModuleToExchangeCompany $connectCompanyModuleToExchangeCompany)
|
public function __construct(CreateUserProcessor $createUserProcessor, CreateCompanyProcessor $createCompanyProcessor, CreateCompanyModuleProcessor $createCompanyModuleProcessor, CreateContactProcessor $createContactProcessor, CreatesCompanyConnection $createsCompanyConnection, ApprovesCompanyConnection $approvesCompanyConnection, AssignEmployeeProcessor $assignEmployeeProcessor, UploadIdentityDocumentProcessor $uploadIdentityDocumentProcessor, AuthenticationProcessor $authenticationProcessor, GenerateEmailVerificationAttemptProcessor $generateEmailVerificationAttemptProcessor, FetchesCompanyModule $fetchesCompanyModule, CreatePerfexCRMLeadProcessor $createPerfexCRMLeadProcessor)
|
||||||
{
|
{
|
||||||
$this->createUserProcessor = $createUserProcessor;
|
$this->createUserProcessor = $createUserProcessor;
|
||||||
$this->createCompanyProcessor = $createCompanyProcessor;
|
$this->createCompanyProcessor = $createCompanyProcessor;
|
||||||
@@ -127,8 +116,6 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
$this->generateEmailVerificationAttemptProcessor = $generateEmailVerificationAttemptProcessor;
|
||||||
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
$this->fetchesCompanyModule = $fetchesCompanyModule;
|
||||||
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
$this->createPerfexCRMLeadProcessor = $createPerfexCRMLeadProcessor;
|
||||||
$this->registerOnExchangeProcessor = $registerOnExchangeProcessor;
|
|
||||||
$this->connectCompanyModuleToExchangeCompany = $connectCompanyModuleToExchangeCompany;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +153,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->assignEmployeeProcessor->execute($Object);
|
$this->assignEmployeeProcessor->execute($Object);
|
||||||
|
|
||||||
// $this->uploadIdentityDocumentProcessor->execute($request, $company);
|
$this->uploadIdentityDocumentProcessor->execute($request, $company);
|
||||||
|
|
||||||
if(config('perfexcrm.is_enabled') == 'true'){
|
if(config('perfexcrm.is_enabled') == 'true'){
|
||||||
// $this->createPerfexCRMLeadProcessor->execute($request);
|
// $this->createPerfexCRMLeadProcessor->execute($request);
|
||||||
@@ -174,40 +161,13 @@ class CreateCustomerLogic extends AbstractControllerLogic
|
|||||||
$request->input('name'),
|
$request->input('name'),
|
||||||
$request->input('email'),
|
$request->input('email'),
|
||||||
$request->input('phone'),
|
$request->input('phone'),
|
||||||
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name'),
|
$request->input('type') === CompanyType::COMPANY_BUSINESS ? $request->input('company_name') : $request->input('name')
|
||||||
$connection->invitee_reference
|
|
||||||
);
|
);
|
||||||
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(app()->environment(['production'])){
|
|
||||||
// call wac webhook
|
|
||||||
$url = config('wagWebhookUrl.account_registration_url');
|
|
||||||
$payload = [
|
|
||||||
'name' => $request->input('name'),
|
|
||||||
'email' => $request->input('email'),
|
|
||||||
'phone' => $request->input('phone'),
|
|
||||||
'portal' => 'izyim'
|
|
||||||
];
|
|
||||||
$response = Http::post($url, $payload);
|
|
||||||
Log::channel('wac_webhook')->info('Register Account: ' . json_encode($response));
|
|
||||||
}
|
|
||||||
|
|
||||||
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
// $this->generateEmailVerificationAttemptProcessor->execute($user);
|
||||||
|
|
||||||
$exchangeCompanyId = null;
|
|
||||||
if ($request->input('exchange_company_id')) {
|
|
||||||
$exchangeCompanyId = $request->input('exchange_company_id');
|
|
||||||
} else {
|
|
||||||
// register account on exchange portal if this registration not coming from exchange
|
|
||||||
$exchangeCompanyId = $this->registerOnExchangeProcessor->execute($request, $companyModule->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($exchangeCompanyId) {
|
|
||||||
// create exchange company connection
|
|
||||||
$this->connectCompanyModuleToExchangeCompany->execute($companyModule, $exchangeCompanyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response($this->authenticationProcessor->execute($request));
|
return $this->response($this->authenticationProcessor->execute($request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessUnauthorisedException;
|
|
||||||
use App\Classes\Modules\Accounts\Processors\AuthenticationProcessor;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationToken;
|
|
||||||
use App\Classes\Modules\Accounts\Services\GeneratesAuthenticationTokenWithExchangeBookingId;
|
|
||||||
use App\Models\ExchangeCompanyConnection;
|
|
||||||
use App\Models\Order;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class LoginThroughExchangeLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Authentication',
|
|
||||||
'message' => 'You have successfully logged in to your account'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var AuthenticationProcessor */
|
|
||||||
private $authenticationProcessor;
|
|
||||||
|
|
||||||
/** @var GeneratesAuthenticationToken */
|
|
||||||
private $generatesAuthenticationToken;
|
|
||||||
|
|
||||||
/** @var GeneratesAuthenticationTokenWithExchangeBookingId */
|
|
||||||
private $generatesAuthenticationTokenWithExchangeBookingId;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LoginThroughExchangeLogic constructor.
|
|
||||||
* @param AuthenticationProcessor $authenticationProcessor
|
|
||||||
* @param GeneratesAuthenticationToken $generatesAuthenticationToken
|
|
||||||
* @param GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId
|
|
||||||
*/
|
|
||||||
public function __construct(GeneratesAuthenticationToken $generatesAuthenticationToken, GeneratesAuthenticationTokenWithExchangeBookingId $generatesAuthenticationTokenWithExchangeBookingId)
|
|
||||||
{
|
|
||||||
$this->generatesAuthenticationToken = $generatesAuthenticationToken;
|
|
||||||
$this->generatesAuthenticationTokenWithExchangeBookingId = $generatesAuthenticationTokenWithExchangeBookingId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
||||||
* @throws \App\Classes\Exceptions\AccessUnauthorisedException
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
protected function logic(Request $request): JsonResponse {
|
|
||||||
|
|
||||||
$token = explode('.', $request->input("exchangeToken"))[1];
|
|
||||||
$decodedToken = base64_decode($token);
|
|
||||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
|
||||||
$exchangeCompanyId = $exchangeUser['company_id'];
|
|
||||||
$connection = ExchangeCompanyConnection::where("exchange_company_id", $exchangeCompanyId)->first();
|
|
||||||
if (!$connection) {
|
|
||||||
throw new AccessUnauthorisedException('These credentials do not match our records.');
|
|
||||||
}
|
|
||||||
$companyModule = $connection->companyModule;
|
|
||||||
$user = $companyModule->employees->last();
|
|
||||||
|
|
||||||
$exchangeBookingId = null;
|
|
||||||
if (isset($exchangeUser['booking_id']) && $exchangeUser['booking_id']) {
|
|
||||||
$exchangeBookingId = $exchangeUser['booking_id'];
|
|
||||||
$token = $this->generatesAuthenticationTokenWithExchangeBookingId->execute($user, $exchangeBookingId);
|
|
||||||
|
|
||||||
return $this->response(['access_token' => $token, 'redirect_url' => route('dashboard') . "?createOrder=true"]);
|
|
||||||
} else {
|
|
||||||
$token = $this->generatesAuthenticationToken->execute($user);
|
|
||||||
$order = Order::where('id', $request->input("orderId"))->first();
|
|
||||||
|
|
||||||
return $this->response(['access_token' => $token, 'redirect_url' => route('order.show' , $order->reference)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ namespace App\Classes\Modules\Accounts\ControllersLogic;
|
|||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Accounts\Services\UpdatesUserFullName;
|
use App\Classes\Modules\Accounts\Services\UpdatesUser;
|
||||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
||||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||||
@@ -29,8 +29,8 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
/** @var CanUpdateUser */
|
/** @var CanUpdateUser */
|
||||||
private $canUpdateUser;
|
private $canUpdateUser;
|
||||||
|
|
||||||
/** @var UpdatesUserFullName */
|
/** @var UpdatesUser */
|
||||||
private $updatesUserFullName;
|
private $updatesUser;
|
||||||
|
|
||||||
/** @var FetchesUser */
|
/** @var FetchesUser */
|
||||||
private $fetchesUser;
|
private $fetchesUser;
|
||||||
@@ -38,13 +38,13 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* UpdateAddressLogic constructor.
|
* UpdateAddressLogic constructor.
|
||||||
* @param CanUpdateUser $canUpdateUser
|
* @param CanUpdateUser $canUpdateUser
|
||||||
* @param UpdatesUserFullName $updatesUserFullName
|
* @param UpdatesUser $updatesUser
|
||||||
* @param FetchesUser $fetchesUSer
|
* @param FetchesUser $fetchesUSer
|
||||||
*/
|
*/
|
||||||
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUserFullName $updatesUserFullName, FetchesUser $fetchesUser)
|
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
|
||||||
{
|
{
|
||||||
$this->canUpdateUser = $canUpdateUser;
|
$this->canUpdateUser = $canUpdateUser;
|
||||||
$this->updatesUserFullName = $updatesUserFullName;
|
$this->updatesUser = $updatesUser;
|
||||||
$this->fetchesUser = $fetchesUser;
|
$this->fetchesUser = $fetchesUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class UpdateUserLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
$query = $this->updatesUserFullName->execute($query, $object);
|
$query = $this->updatesUser->execute($query, $object);
|
||||||
|
|
||||||
return $this->resourceResponse(new UserResource($query));
|
return $this->resourceResponse(new UserResource($query));
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\ControllersLogic;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
||||||
use App\Classes\Modules\Accounts\Services\UpdatesUser;
|
|
||||||
use App\Classes\Modules\Accounts\Services\FetchesUser;
|
|
||||||
use App\Classes\Modules\Accounts\Standards\Rules\CanUpdateUser;
|
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
|
||||||
use App\Http\Resources\UserResource;
|
|
||||||
use ErrorException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class UpdateUserRoleLogic extends AbstractControllerLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function notification():array {
|
|
||||||
return [
|
|
||||||
'title' => 'Updated Admin Role',
|
|
||||||
'message' => 'You have successfully updated the Admin Role'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var CanUpdateUser */
|
|
||||||
private $canUpdateUser;
|
|
||||||
|
|
||||||
/** @var UpdatesUser */
|
|
||||||
private $updatesUser;
|
|
||||||
|
|
||||||
/** @var FetchesUser */
|
|
||||||
private $fetchesUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateAddressLogic constructor.
|
|
||||||
* @param CanUpdateUser $canUpdateUser
|
|
||||||
* @param UpdatesUser $updatesUser
|
|
||||||
* @param FetchesUser $fetchesUSer
|
|
||||||
*/
|
|
||||||
public function __construct(CanUpdateUser $canUpdateUser, UpdatesUser $updatesUser, FetchesUser $fetchesUser)
|
|
||||||
{
|
|
||||||
$this->canUpdateUser = $canUpdateUser;
|
|
||||||
$this->updatesUser = $updatesUser;
|
|
||||||
$this->fetchesUser = $fetchesUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return JsonResponse
|
|
||||||
* @throws ErrorException
|
|
||||||
*/
|
|
||||||
public function logic(Request $request) : JsonResponse
|
|
||||||
{
|
|
||||||
$query = $this->fetchesUser->execute(['id' => $request->route('id')]);
|
|
||||||
|
|
||||||
$object = new UserObject($query->name, $request->input('type'));
|
|
||||||
|
|
||||||
$this->canUpdateUser->passes($object);
|
|
||||||
|
|
||||||
$query = $this->updatesUser->execute($query, $object);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new UserResource($query));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class KeyValuePairObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $key;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $value;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* KeyValuePairObject constructor.
|
|
||||||
* @param string $key
|
|
||||||
* @param string $value
|
|
||||||
*/
|
|
||||||
public function __construct(string $key, string $value)
|
|
||||||
{
|
|
||||||
$this->key = $key;
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getKey(): string
|
|
||||||
{
|
|
||||||
return $this->key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getValue(): string
|
|
||||||
{
|
|
||||||
return $this->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\DataTransferObjects;
|
|
||||||
|
|
||||||
use App\Classes\General\Interfaces\DataTransferObject;
|
|
||||||
|
|
||||||
class UserObject implements DataTransferObject
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FullNameObject constructor.
|
|
||||||
* @param string $name
|
|
||||||
*/
|
|
||||||
public function __construct(string $name, int $type)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getType(): int
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\Processors;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class RegisterOnExchangeProcessor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return string
|
|
||||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
||||||
*/
|
|
||||||
public function execute(Request $request, $companyModuleId) {
|
|
||||||
if (App::environment(['production'])) {
|
|
||||||
dd("Delete this line before push to production");
|
|
||||||
$url = 'https://exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
|
||||||
} else if (App::environment(['local'])) {
|
|
||||||
$url = 'http://127.0.0.1:8000/api/v1/account/registration/registration';
|
|
||||||
} else {
|
|
||||||
$url = 'https://dev.exchange.cief-malaysia.com/api/v1/account/registration/registration';
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$client = new \GuzzleHttp\Client(['verify' => false]);
|
|
||||||
$formParams = $request->toArray();
|
|
||||||
$formParams['shipping_company_module_id'] = $companyModuleId;
|
|
||||||
$response = $client->request('POST', $url, ['form_params' => $formParams]);
|
|
||||||
$body = $response->getBody();
|
|
||||||
$contents = json_decode($body, true);
|
|
||||||
$payload = $contents['payload'];
|
|
||||||
$token = explode('.', $payload['access_token'])[1];
|
|
||||||
$decodedToken = base64_decode($token);
|
|
||||||
$exchangeUser = json_decode($decodedToken, true)['user'];
|
|
||||||
|
|
||||||
return $exchangeUser['company_id'];
|
|
||||||
} catch(\GuzzleHttp\Exception\RequestException $exception){
|
|
||||||
Log::error($exception->getResponse()->getBody()->getContents());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\Services;
|
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
|
|
||||||
use App\Classes\General\Interfaces\KeyValueInterface;
|
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\KeyValuePairObject;
|
|
||||||
use App\Models\KeyValuePair;
|
|
||||||
|
|
||||||
class CreatesKeyValuePair extends AbstractUpdateRelationshipRecord
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param KeyValueInterface $kv
|
|
||||||
* @param KeyValuePairObject $object
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function execute(KeyValueInterface $kv, KeyValuePairObject $object) {
|
|
||||||
$model = new KeyValuePair();
|
|
||||||
$model->key = $object->getKey();
|
|
||||||
$model->value = $object->getValue();
|
|
||||||
|
|
||||||
return $this->handler($kv->attributes(), $model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-81
@@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\Services;
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\InternalServerErrorException;
|
|
||||||
use App\Classes\ValueObjects\Constants\OrderRoleTypes;
|
|
||||||
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\Role;
|
|
||||||
use App\Models\User;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Tymon\JWTAuth\JWT;
|
|
||||||
|
|
||||||
class GeneratesAuthenticationTokenWithExchangeBookingId {
|
|
||||||
|
|
||||||
/** @var JWT */
|
|
||||||
private $builder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GeneratesAuthenticationTokenWithExchangeBookingId constructor.
|
|
||||||
* @param JWT $builder
|
|
||||||
*/
|
|
||||||
public function __construct(JWT $builder) {
|
|
||||||
$this->builder = $builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
* @param bool $rememberUser
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function execute(User $user, $bookingId): string {
|
|
||||||
|
|
||||||
$this->builder->manager()->setBlacklistEnabled(false);
|
|
||||||
|
|
||||||
// generate token for the customer
|
|
||||||
$this->builder->factory()->setTTL(Carbon::now()->addDay()->timestamp);
|
|
||||||
|
|
||||||
// set the claim based on the object
|
|
||||||
$this->setTokenClaims($user, $bookingId);
|
|
||||||
|
|
||||||
return $this->builder->fromUser($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $user
|
|
||||||
*/
|
|
||||||
private function setTokenClaims(User $user, $bookingId): void {
|
|
||||||
|
|
||||||
$claims = [
|
|
||||||
'id' => $user->id,
|
|
||||||
'name' => $user->name,
|
|
||||||
'email' => $user->email,
|
|
||||||
'type' => $user->type,
|
|
||||||
'status' => $user->status
|
|
||||||
];
|
|
||||||
|
|
||||||
if($user->type === RoleTypes::USER) {
|
|
||||||
|
|
||||||
/** @var Company $companyModule */
|
|
||||||
$companyModule = $user->companyModule()->first();
|
|
||||||
|
|
||||||
$claims = array_merge($claims, [
|
|
||||||
'company_id' => $companyModule->company_id,
|
|
||||||
'company_module_id' => $companyModule->id,
|
|
||||||
'company_module_type' => $companyModule->type,
|
|
||||||
'company_name' => $companyModule->name,
|
|
||||||
'company_marking' => $companyModule->type !== 8 ? $companyModule->inviters()->withPivot('invitee_reference')->first()->pivot->invitee_reference : 'HWT',
|
|
||||||
'exchange_booking_id' => $bookingId
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->builder->factory()->customClaims(['user' => $claims]);
|
|
||||||
|
|
||||||
|
|
||||||
$this->builder->factory()->buildClaimsCollection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Classes\Modules\Accounts\Services;
|
namespace App\Classes\Modules\Accounts\Services;
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\UserObject;
|
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
class UpdatesUser extends AbstractUpdateRecord
|
class UpdatesUser extends AbstractUpdateRecord
|
||||||
@@ -11,14 +11,13 @@ class UpdatesUser extends AbstractUpdateRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $model
|
* @param User $model
|
||||||
* @param UserObject $object
|
* @param FullNameObject $object
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
* @return \Illuminate\Database\Eloquent\Model
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
*/
|
*/
|
||||||
public function execute(User $model, UserObject $object) {
|
public function execute(User $model, FullNameObject $object) {
|
||||||
|
|
||||||
$model->name = $object->getName();
|
$model->name = $object->getName();
|
||||||
$model->type = $object->getType();
|
|
||||||
return $this->handler($model);
|
return $this->handler($model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Classes\Modules\Accounts\Services;
|
|
||||||
|
|
||||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
|
||||||
use App\Classes\Modules\Accounts\DataTransferObjects\FullNameObject;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class UpdatesUserFullName extends AbstractUpdateRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param User $model
|
|
||||||
* @param FullNameObject $object
|
|
||||||
* @return \Illuminate\Database\Eloquent\Model
|
|
||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
||||||
*/
|
|
||||||
public function execute(User $model, FullNameObject $object) {
|
|
||||||
|
|
||||||
$model->name = $object->getName();
|
|
||||||
return $this->handler($model);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,7 +26,7 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -54,4 +54,4 @@ class CanAuthenticateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanCreateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ class CanCrossAuthenticateUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ class CanDeleteUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ class CanFetchUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanFetchUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanGeneratePasswordReset extends AbstractRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class CanListUsers extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -39,4 +39,4 @@ class CanListUsers extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class CanRegisterUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -48,4 +48,4 @@ class CanRegisterUser extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ class CanResetPassword extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ class CanResetPassword extends AbstractRule
|
|||||||
return $this->passwordResetTokenExists->execute($object->getToken());
|
return $this->passwordResetTokenExists->execute($object->getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanUpdateUser extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateUser extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\General\Interfaces\Contactable;
|
use App\Classes\General\Interfaces\Contactable;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
@@ -18,10 +15,8 @@ use App\Classes\Modules\Contacts\Processors\CreateContactProcessor;
|
|||||||
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -32,8 +27,7 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Address',
|
'title' => 'Created Address',
|
||||||
'message' => 'You have successfully created a new Address'
|
'message' => 'You have successfully created a new Address'
|
||||||
@@ -80,11 +74,11 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
@@ -96,31 +90,16 @@ class CreateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
$address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object);
|
||||||
|
|
||||||
if ($request->input('phone')) {
|
if($request->input('phone')){
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('remark')) {
|
if($request->input('remark')){
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
$addressExtraFields = [
|
|
||||||
'property_type' => $request->input('property_type'),
|
|
||||||
'tools_required_unload' => $request->input('tools_required_unload'),
|
|
||||||
'pickup_time_from' => $request->input('pickup_time_from'),
|
|
||||||
'pickup_time_to' => $request->input('pickup_time_to'),
|
|
||||||
];
|
|
||||||
|
|
||||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
|
||||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
use App\Classes\Modules\Addresses\Services\CreatesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanCreateAddress;
|
||||||
@@ -17,7 +14,6 @@ use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Models\CompanyModule;
|
use App\Models\CompanyModule;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -27,8 +23,7 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Created Billing Address',
|
'title' => 'Created Billing Address',
|
||||||
'message' => 'You have successfully created a new Billing Address'
|
'message' => 'You have successfully created a new Billing Address'
|
||||||
@@ -65,14 +60,14 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
$companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]);
|
||||||
|
|
||||||
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
$billingAddressInputed = $this->fetchesAddress->execute(['id' => $request->input('billing_address_id')]);
|
||||||
|
|
||||||
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
if ($billingAddressInputed->type !== AddressType::BILLING || $billingAddressInputed->id !== $companyModule->addresses->where('type', AddressType::BILLING)->first()->id) {
|
||||||
@@ -85,14 +80,6 @@ class CreateBillingAddressLogic extends AbstractControllerLogic
|
|||||||
$this->createsAddress->execute($companyModule, $billingAddress);
|
$this->createsAddress->execute($companyModule, $billingAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
//load address with only owner address
|
|
||||||
|
|
||||||
/* return fractal()
|
|
||||||
->item($billingAddressInputed, new AddressTransformer())
|
|
||||||
->parseIncludes('Owner_address')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
return $this->resourceResponse(new AddressResource($billingAddressInputed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
||||||
@@ -19,8 +17,7 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Address',
|
'title' => 'Retrieved Address',
|
||||||
'message' => 'You have successfully retrieved a Address'
|
'message' => 'You have successfully retrieved a Address'
|
||||||
@@ -48,22 +45,15 @@ class FetchAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$this->canFetchAddress->passes();
|
$this->canFetchAddress->passes();
|
||||||
|
|
||||||
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
||||||
|
|
||||||
|
|
||||||
//load address with no relationships
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($query));
|
return $this->resourceResponse(new AddressResource($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,10 @@
|
|||||||
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
||||||
|
|
||||||
|
|
||||||
use App\Classes\Exceptions\AccessForbiddenException;
|
|
||||||
use App\Classes\Exceptions\MalformedRequestException;
|
|
||||||
use App\Classes\Exceptions\RequestValidationException;
|
|
||||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -21,8 +17,7 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Retrieved Addresses',
|
'title' => 'Retrieved Addresses',
|
||||||
'message' => 'You have successfully retrieved a list of Addresses'
|
'message' => 'You have successfully retrieved a list of Addresses'
|
||||||
@@ -50,25 +45,17 @@ class ListAddressesLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws AccessForbiddenException
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||||
* @throws MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->canListAddresses->passes();
|
$this->canListAddresses->passes();
|
||||||
|
|
||||||
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
$query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters')));
|
||||||
|
|
||||||
//a collection of addresses with all incluides
|
|
||||||
/* return fractal()
|
|
||||||
->collection($query, new AddressTransformer)
|
|
||||||
->parseIncludes('Owner_address')
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->parseIncludes('contact')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
return $this->collectionResponse(AddressResource::collection($query));
|
return $this->collectionResponse(AddressResource::collection($query));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
use App\Classes\Modules\Addresses\Services\ListsDistricts;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Http\Resources\DistrictResource;
|
use App\Http\Resources\DistrictResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|||||||
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
use App\Classes\Modules\Addresses\Services\ListsAddresses;
|
||||||
use App\Classes\Modules\Addresses\Services\ListsStates;
|
use App\Classes\Modules\Addresses\Services\ListsStates;
|
||||||
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
use App\Classes\Modules\Addresses\Standards\Rules\CanListAddresses;
|
||||||
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Http\Resources\StateResource;
|
use App\Http\Resources\StateResource;
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|||||||
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault;
|
||||||
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
use App\Classes\Modules\Addresses\Services\SetsAddressToDefault;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
/** @var ResetsAddressesDefault */
|
/** @var ResetsAddressesDefault */
|
||||||
private $resetsAddressesDefault;
|
private $resetsAddressesDefault;
|
||||||
|
|
||||||
/** @var SetsAddressToDefault */
|
/** @var SetsAddressToDefault*/
|
||||||
private $setsAddressToDefault;
|
private $setsAddressToDefault;
|
||||||
|
|
||||||
|
|
||||||
@@ -65,15 +64,7 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic
|
|||||||
|
|
||||||
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
$this->resetsAddressesDefault->execute($address->owner, $address->type);
|
||||||
|
|
||||||
|
return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address)));
|
||||||
$setAddress = $this->setsAddressToDefault->execute($address);
|
|
||||||
//no relationships needed
|
|
||||||
/* return fractal()
|
|
||||||
->item($setAddress, new AddressTransformer())
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,10 @@ use App\Classes\Modules\Remarks\DataTransferObjects\RemarkObject;
|
|||||||
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
|
||||||
use App\Classes\ValueObjects\Constants\AddressType;
|
use App\Classes\ValueObjects\Constants\AddressType;
|
||||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||||
use App\Classes\ValueObjects\Constants\RemarkTypes;
|
|
||||||
use App\Http\Resources\AddressResource;
|
use App\Http\Resources\AddressResource;
|
||||||
use App\Models\Address;
|
use App\Models\Address;
|
||||||
use App\Transformers\AddressTransformer;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Carbon\Carbon;
|
|
||||||
|
|
||||||
class UpdateAddressLogic extends AbstractControllerLogic
|
class UpdateAddressLogic extends AbstractControllerLogic
|
||||||
{
|
{
|
||||||
@@ -29,8 +26,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function notification(): array
|
protected function notification():array {
|
||||||
{
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Updated Address',
|
'title' => 'Updated Address',
|
||||||
'message' => 'You have successfully updated the Address'
|
'message' => 'You have successfully updated the Address'
|
||||||
@@ -81,7 +77,7 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||||
*/
|
*/
|
||||||
public function logic(Request $request): JsonResponse
|
public function logic(Request $request) : JsonResponse
|
||||||
{
|
{
|
||||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||||
|
|
||||||
@@ -94,44 +90,18 @@ class UpdateAddressLogic extends AbstractControllerLogic
|
|||||||
/** @var Address $address */
|
/** @var Address $address */
|
||||||
$address = $this->updatesAddress->execute($address, $object);
|
$address = $this->updatesAddress->execute($address, $object);
|
||||||
|
|
||||||
$address->contacts()->delete();
|
$address->contacts()->delete(); $address->remarks()->delete();
|
||||||
$address->remarks()->delete();
|
|
||||||
|
|
||||||
if ($request->input('phone')) {
|
if($request->input('phone')){
|
||||||
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
$contactObject = new ContactObject($request->input('person_in_charge'), $request->input('phone'), '', '');
|
||||||
$this->createContactProcessor->execute($contactObject, $address);
|
$this->createContactProcessor->execute($contactObject, $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->input('remark')) {
|
if($request->input('remark')){
|
||||||
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
$remarkObject = new RemarkObject($request->input('remark'), Auth()->user()->id);
|
||||||
$this->createRemarkProcessor->execute($address, $remarkObject);
|
$this->createRemarkProcessor->execute($address, $remarkObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
//only remark relationship needed
|
|
||||||
/* return fractal()
|
|
||||||
->item($address, new AddressTransformer())
|
|
||||||
->parseIncludes('remark')
|
|
||||||
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
||||||
|
|
||||||
if ($request->input('pickup_time_to') <= $request->input('pickup_time_from')) {
|
|
||||||
$pickupTimeFrom = Carbon::parse($request->input('pickup_time_from'));
|
|
||||||
$request->merge([
|
|
||||||
'pickup_time_to' => $pickupTimeFrom->addHour()->format('H:i') // Format to hh:mm
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$addressExtraFields = [
|
|
||||||
'property_type' => $request->input('property_type'),
|
|
||||||
'additional_request' => $request->input('additional_request'),
|
|
||||||
'receive_goods_working_hours' => $request->input('receive_goods_working_hours'),
|
|
||||||
'receive_goods_after_hours' => $request->input('receive_goods_after_hours'),
|
|
||||||
'receive_goods_on_saturday' => $request->input('receive_goods_on_saturday'),
|
|
||||||
];
|
|
||||||
|
|
||||||
$address->addressExtraFields()->delete();
|
|
||||||
$addressExtraFieldsObject = new RemarkObject(json_encode($addressExtraFields), Auth()->user()->id, RemarkTypes::ADDRESS_EXTRA_COLUMNS);
|
|
||||||
$this->createRemarkProcessor->execute($address, $addressExtraFieldsObject);
|
|
||||||
|
|
||||||
return $this->resourceResponse(new AddressResource($address));
|
return $this->resourceResponse(new AddressResource($address));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanCreateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanCreateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanDeleteAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class CanFetchAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanFetchAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class CanListAddresses extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -40,4 +40,4 @@ class CanListAddresses extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -54,4 +54,4 @@ class CanUpdateAddress extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ use App\Classes\Modules\Announcements\Services\FetchesAnnouncement;
|
|||||||
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
use App\Classes\Modules\Announcements\Services\UpdatesAnnouncement;
|
||||||
|
|
||||||
use App\Http\Resources\AnnouncementResource;
|
use App\Http\Resources\AnnouncementResource;
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ class UpdateAnnouncementLogic extends AbstractControllerLogic
|
|||||||
$annoucement_object = new AnnouncementObject(
|
$annoucement_object = new AnnouncementObject(
|
||||||
$request->input('title'),
|
$request->input('title'),
|
||||||
$request->input('description'),
|
$request->input('description'),
|
||||||
Carbon::createFromFormat('d-m-Y', $request->input('starting_on'))->format('Y-m-d H:i:s'),
|
$request->input('starting_on'),
|
||||||
Carbon::createFromFormat('d-m-Y', $request->input('ending_on'))->format('Y-m-d H:i:s')
|
$request->input('ending_on')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->canUpdateAnnouncement->passes($annoucement_object);
|
$this->canUpdateAnnouncement->passes($annoucement_object);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class AssignsAnnouncementToSegment extends AbstractUpdateRecord
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$announcement->segments()->attach($segment, ['created_at' => now(), 'updated_at' => now()]);
|
$announcement->segments()->attach($segment);
|
||||||
|
|
||||||
return $announcement;
|
return $announcement;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CanAssignSegment extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanAssignSegment extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -47,4 +47,4 @@ class CanCreateAnnouncement extends AbstractRule
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -37,4 +37,4 @@ class CanDeleteAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class CanListAnnouncements extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function authorized($object): bool
|
protected function authorized(): bool
|
||||||
{
|
{
|
||||||
// TODO Set Authorization rules
|
// TODO Set Authorization rules
|
||||||
return true;
|
return true;
|
||||||
@@ -51,4 +51,4 @@ class CanUpdateAnnouncement extends AbstractRule
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user