mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
Vue Polling for /dashboard page
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\Bookings\Processors\ListBookingJobProcessor;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
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\JobResult;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ListBookings implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var ListGenericJobObject */
|
||||
private $listGenericJobObject;
|
||||
|
||||
private $jobId;
|
||||
|
||||
/**
|
||||
* ListBookings constructor.
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
*/
|
||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||
{
|
||||
$this->listGenericJobObject = $listGenericJobObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$result = (App()->make(ListBookingJobProcessor::class))->execute($this->listGenericJobObject);
|
||||
}
|
||||
|
||||
public function getJobId(){
|
||||
return $this->job->getJobId();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\Documents\Processors\ListDocumentProcessor;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\ListDocumentJobObject;
|
||||
use App\Classes\Modules\Documents\Processors\ListDocumentJobProcessor;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -16,23 +16,23 @@ class ListDocuments implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var ListDocumentJobObject */
|
||||
private $listDocumentJobObject;
|
||||
/** @var ListGenericJobObject */
|
||||
private $listGenericJobObject;
|
||||
|
||||
private $jobId;
|
||||
|
||||
/**
|
||||
* ListDocuments constructor.
|
||||
* @param ListDocumentJobObject $listDocumentJobObject
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
*/
|
||||
public function __construct(ListDocumentJobObject $listDocumentJobObject)
|
||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||
{
|
||||
$this->listDocumentJobObject = $listDocumentJobObject;
|
||||
$this->listGenericJobObject = $listGenericJobObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$result = (App()->make(ListDocumentProcessor::class))->execute($this->listDocumentJobObject);
|
||||
$result = (App()->make(ListDocumentJobProcessor::class))->execute($this->listGenericJobObject);
|
||||
|
||||
// Log::error(json_encode($result));
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\Transactions\Processors\ListTransactionJobProcessor;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
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\JobResult;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ListTransactions implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var ListGenericJobObject */
|
||||
private $listGenericJobObject;
|
||||
|
||||
private $jobId;
|
||||
|
||||
/**
|
||||
* ListTransactions constructor.
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
*/
|
||||
public function __construct(ListGenericJobObject $listGenericJobObject)
|
||||
{
|
||||
$this->listGenericJobObject = $listGenericJobObject;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$result = (App()->make(ListTransactionJobProcessor::class))->execute($this->listGenericJobObject);
|
||||
}
|
||||
|
||||
public function getJobId(){
|
||||
return $this->job->getJobId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Bookings\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\ListBookings;
|
||||
use App\Classes\Modules\Bookings\Standards\Rules\CanListBookings;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ListBookingJobLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Booking Job',
|
||||
'message' => 'You have successfully submit a job to list bookings'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$jobId = uniqid();
|
||||
|
||||
$user = Auth::user();
|
||||
$userInfo = (object) [
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
];
|
||||
|
||||
$listGenericJobObject = new ListGenericJobObject(
|
||||
"Proof of Concept",
|
||||
$request->all(),
|
||||
$jobId,
|
||||
$userInfo
|
||||
);
|
||||
|
||||
ListBookings::dispatch($listGenericJobObject);
|
||||
|
||||
$result = [];
|
||||
$result['job_id'] = $jobId;
|
||||
|
||||
return $this->response(['data' => $result]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Bookings\Processors;
|
||||
|
||||
use App\Classes\Modules\Bookings\Services\ListsBookings;
|
||||
use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Http\Resources\BookingResource;
|
||||
|
||||
class ListBookingJobProcessor
|
||||
{
|
||||
|
||||
/** @var ListsBookings */
|
||||
private $listsBookings;
|
||||
|
||||
/** @var CreatesJobResult */
|
||||
private $createsJobResult;
|
||||
|
||||
/**
|
||||
* ListBookingJobProcessor constructor.
|
||||
* @param ListsBookings $listsBookings
|
||||
* @param CreatesJobResult $createsJobResult
|
||||
*/
|
||||
public function __construct(ListsBookings $listsBookings, CreatesJobResult $createsJobResult)
|
||||
{
|
||||
$this->listsBookings = $listsBookings;
|
||||
$this->createsJobResult = $createsJobResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsBookings->execute($this->listsBookings->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
Log::error('ListBookingJobProcessor: '. json_encode($listGenericJobObject->getuserInfo()));
|
||||
Log::error('ListBookingJobProcessor: '. json_encode(gettype($query)));
|
||||
|
||||
// $result = $this->collectionResponse(BookingResource::collection($query)->userInfo($listGenericJobObject->getuserInfo()));
|
||||
$result = $this->collectionResponse(BookingResource::customResourceCollection($query, $listGenericJobObject->getuserInfo()));
|
||||
|
||||
// $result = new JobBookingCollectionResponse($query, $listGenericJobObject->getuserInfo());
|
||||
// $result = $this->collectionResponse(new BookingResourceCollection(BookingResource::collection($query), $listGenericJobObject->getuserInfo()));
|
||||
|
||||
$create = $this->createsJobResult->execute($listGenericJobObject->getJobId(), json_encode($result));
|
||||
|
||||
return $create;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCollection $collection
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function collectionResponse(ResourceCollection $collection){
|
||||
return json_decode($collection->response()->getContent(), true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\ListDocumentJobObject;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Classes\Jobs\ListDocuments;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use ErrorException;
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Helper;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ListDocumentJobLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -22,8 +23,8 @@ class ListDocumentJobLogic extends AbstractControllerLogic
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Job',
|
||||
'message' => 'You have successfully submit a job to list Documents'
|
||||
'title' => 'List Document Job',
|
||||
'message' => 'You have successfully submit a job to list documents'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -34,18 +35,25 @@ class ListDocumentJobLogic extends AbstractControllerLogic
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$jobId = uniqid();
|
||||
Log::error(json_encode($request->all()));
|
||||
|
||||
$listDocumentJobObject = new ListDocumentJobObject(
|
||||
$user = Auth::user();
|
||||
$userInfo = (object) [
|
||||
'email' => $user->email,
|
||||
'type' => $user->type,
|
||||
];
|
||||
|
||||
|
||||
$listGenericJobObject = new ListGenericJobObject(
|
||||
"Proof of Concept",
|
||||
$request->all(),
|
||||
$jobId
|
||||
$jobId,
|
||||
$userInfo
|
||||
);
|
||||
|
||||
ListDocuments::dispatch($listDocumentJobObject);
|
||||
ListDocuments::dispatch($listGenericJobObject);
|
||||
|
||||
// // Create your job instance with delay, so we can back here within delay and take control in our hands.
|
||||
// $job = new ListDocuments($listDocumentJobObject);
|
||||
// $job = new ListDocuments($listGenericJobObject);
|
||||
// $job->delay(now()->addSeconds(5));
|
||||
|
||||
// // Dispath your job with our custom_dispatch helper. This will return job id from jobs table
|
||||
|
||||
+15
-10
@@ -7,12 +7,12 @@ use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\ListDocumentJobObject;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use App\Http\Controllers\Documents\ListDocumentsController;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
|
||||
class ListDocumentProcessor
|
||||
class ListDocumentJobProcessor
|
||||
{
|
||||
|
||||
/** @var ListsDocuments */
|
||||
@@ -22,7 +22,7 @@ class ListDocumentProcessor
|
||||
private $createsJobResult;
|
||||
|
||||
/**
|
||||
* ListDocumentProcessor constructor.
|
||||
* ListDocumentJobProcessor constructor.
|
||||
* @param ListsDocuments $listsDocuments
|
||||
* @param CreatesJobResult $createsJobResult
|
||||
*/
|
||||
@@ -33,19 +33,24 @@ class ListDocumentProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ListDocumentJobObject $listDocumentJobObject
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ListDocumentJobObject $listDocumentJobObject) {
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($listDocumentJobObject->getPayload()['filters']), ['page' => $listDocumentJobObject->getPayload()['page']]);
|
||||
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
Log::error('ListDocumentJobProcessor: '. json_encode($listGenericJobObject->getuserInfo()));
|
||||
|
||||
// Log::error('page: '.json_encode($listDocumentJobObject->getPayload()['page']));
|
||||
$result = $this->collectionResponse(DocumentResource::collection($query));
|
||||
//attempt 1
|
||||
// $result = $this->collectionResponse(DocumentResource::collection($query, $listGenericJobObject->getuserInfo()));
|
||||
|
||||
Log::error(json_encode($result));
|
||||
$create = $this->createsJobResult->execute($listDocumentJobObject->getJobId(), json_encode($result));
|
||||
//attempt 2
|
||||
// $result = new JobDocumentCollectionResponse($query, $listGenericJobObject->getuserInfo());
|
||||
$result = $this->collectionResponse(DocumentResource::customResourceCollection($query, $listGenericJobObject->getuserInfo()));
|
||||
// $result = $this->collectionResponse(new DocumentResourceCollection(DocumentResource::collection($query), $listGenericJobObject->getuserInfo()));
|
||||
|
||||
$create = $this->createsJobResult->execute($listGenericJobObject->getJobId(), json_encode($result));
|
||||
|
||||
return $create;
|
||||
}
|
||||
+14
-3
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\DataTransferObjects;
|
||||
namespace App\Classes\Modules\Generic\DataTransferObjects;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\General\Interfaces\DataTransferObject;
|
||||
|
||||
class ListDocumentJobObject implements DataTransferObject
|
||||
class ListGenericJobObject implements DataTransferObject
|
||||
{
|
||||
/** @var string */
|
||||
private $name;
|
||||
@@ -16,12 +16,15 @@ class ListDocumentJobObject implements DataTransferObject
|
||||
/** @var string */
|
||||
private $jobId;
|
||||
|
||||
/** @var object */
|
||||
private $userInfo;
|
||||
|
||||
public function __construct(string $name, array $payload, string $jobId)
|
||||
public function __construct(string $name, array $payload, string $jobId, object $userInfo = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->payload = $payload;
|
||||
$this->jobId = $jobId;
|
||||
$this->userInfo = $userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +51,14 @@ class ListDocumentJobObject implements DataTransferObject
|
||||
return $this->jobId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return object
|
||||
*/
|
||||
public function getUserInfo(): object
|
||||
{
|
||||
return $this->userInfo;
|
||||
}
|
||||
|
||||
// public function setJobId(int $jobId)
|
||||
// {
|
||||
// $this->jobId = $jobId;
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Jobs\ListTransactions;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListTransactionsJobLogic extends AbstractControllerLogic
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'List Transaction Job',
|
||||
'message' => 'You have successfully submit a job to list transactions'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
$jobId = uniqid();
|
||||
|
||||
$listGenericJobObject = new ListGenericJobObject(
|
||||
"Proof of Concept",
|
||||
$request->all(),
|
||||
$jobId
|
||||
);
|
||||
|
||||
ListTransactions::dispatch($listGenericJobObject);
|
||||
|
||||
$result = [];
|
||||
$result['job_id'] = $jobId;
|
||||
|
||||
return $this->response(['data' => $result]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Transactions\Processors;
|
||||
|
||||
use App\Classes\Modules\Transactions\Services\ListsTransactions;
|
||||
use App\Classes\Modules\Jobs\Services\CreatesJobResult;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Http\Resources\TransactionResource;
|
||||
|
||||
class ListTransactionJobProcessor
|
||||
{
|
||||
|
||||
/** @var ListsTransactions */
|
||||
private $listsTransactions;
|
||||
|
||||
/** @var CreatesJobResult */
|
||||
private $createsJobResult;
|
||||
|
||||
/**
|
||||
* ListTransactionJobProcessor constructor.
|
||||
* @param ListsTransactions $listsTransactions
|
||||
* @param CreatesJobResult $createsJobResult
|
||||
*/
|
||||
public function __construct(ListsTransactions $listsTransactions, CreatesJobResult $createsJobResult)
|
||||
{
|
||||
$this->listsTransactions = $listsTransactions;
|
||||
$this->createsJobResult = $createsJobResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ListGenericJobObject $listGenericJobObject
|
||||
* @return null|object
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
*/
|
||||
public function execute(ListGenericJobObject $listGenericJobObject) {
|
||||
|
||||
$query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
|
||||
|
||||
$result = $this->collectionResponse(TransactionResource::collection($query));
|
||||
|
||||
$create = $this->createsJobResult->execute($listGenericJobObject->getJobId(), json_encode($result));
|
||||
|
||||
return $create;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ResourceCollection $collection
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function collectionResponse(ResourceCollection $collection){
|
||||
return json_decode($collection->response()->getContent(), true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Bookings;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Bookings\ControllersLogic\ListBookingJobLogic;
|
||||
|
||||
|
||||
class ListBookingsJobController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListBookingJobLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
|
||||
public function list(Request $request, ListBookingJobLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Documents;
|
||||
|
||||
use App\Classes\Modules\Documents\ControllersLogic\ListDocumentJobLogic;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\ListDocumentJobObject;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Jobs\ListDocuments;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Transactions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\ListTransactionsJobLogic;
|
||||
|
||||
|
||||
class ListTransactionsJobController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ListTransactionsJobLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function list(Request $request, ListTransactionsJobLogic $logic) : JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,19 @@ use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Classes\ValueObjects\Constants\DocumentType;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BookingResource extends JsonResource
|
||||
{
|
||||
// protected $userInfo;
|
||||
private static $userInfo;
|
||||
|
||||
public function userInfo($resource, $userInfo = null)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
self::$userInfo = $userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
@@ -27,7 +36,7 @@ class BookingResource extends JsonResource
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'company' => new CompanyResource($this->company),
|
||||
'company' => new CompanyResource($this->company, self::$userInfo),
|
||||
'bank' => new BankResource($this->bank),
|
||||
'service' => new ServiceTypeResource($this->service),
|
||||
'marking' => $this->marking,
|
||||
@@ -72,4 +81,10 @@ class BookingResource extends JsonResource
|
||||
])
|
||||
];
|
||||
}
|
||||
|
||||
public static function customResourceCollection($resource, $userInfo): AnonymousResourceCollection
|
||||
{
|
||||
self::$userInfo = $userInfo;
|
||||
return parent::collection($resource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class CompanyResource extends JsonResource
|
||||
{
|
||||
protected $userInfo;
|
||||
|
||||
public function __construct($resource, $userInfo = null)
|
||||
{
|
||||
parent::__construct($resource);
|
||||
$this->userInfo = $userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -33,6 +41,26 @@ class CompanyResource extends JsonResource
|
||||
$segment = SegmentConstant::where('reference', SegmentConstants::SUPPLIER_CURRENCIES)->where('detail->id', $this->id)->first();
|
||||
$serviceCharge = SegmentConstant::where('reference', SegmentConstants::SERVICE_CHARGE)->where('detail->id', $this->id)->first();
|
||||
|
||||
$userResource = null;
|
||||
|
||||
$userInfoEmail = $this->userInfo && isset($this->userInfo->email) ? $this->userInfo->email : null;
|
||||
$userInfoType = $this->userInfo && isset($this->userInfo->type) ? $this->userInfo->type : null;
|
||||
|
||||
if(!$userInfoEmail && Auth::user()){
|
||||
$userInfoEmail = Auth::user()->email;
|
||||
}
|
||||
if(!$userInfoType && Auth::user()){
|
||||
$userInfoType = Auth::user()->type;
|
||||
}
|
||||
|
||||
//cief todo: remove
|
||||
// Log::error('CompanyResource 1: '. json_encode($userInfoEmail));
|
||||
// Log::error('CompanyResource 2: '. json_encode($userInfoType));
|
||||
|
||||
if(!is_null($userInfoEmail) && !is_null($userInfoType)){
|
||||
$userResource = new UserResource($userInfoType === RoleTypes::USER ? $this->employees()->where('email', '=', $userInfoEmail)->first() : $this->employees()->orderBy('id', 'DESC')->first());
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
@@ -44,7 +72,7 @@ class CompanyResource extends JsonResource
|
||||
'contact' => new ContactResource ($this->when($this->has('contacts'), $this->contacts->first())),
|
||||
'address' => new AddressResource($this->when($this->has('addresses'), $this->addresses->where('billing', true)->first())),
|
||||
//cief todo: this one need to decide what to do to replace Auth:user() when it is run by job queue
|
||||
// 'employee' => new UserResource(Auth::user()->type === RoleTypes::USER ? $this->employees()->where('email', '=', Auth::user()->email)->first() : $this->employees()->orderBy('id', 'DESC')->first()),
|
||||
'employee' => $userResource,
|
||||
'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->first()),
|
||||
'bookings' => $this->whenLoaded('bookings', $this->bookings()->orderBy('id', 'DESC')->get(), []),
|
||||
'confirmed_bookings' => $this->bookings()->whereHas('transactions', function ($query){
|
||||
|
||||
@@ -8,9 +8,21 @@ use App\Models\Document;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
|
||||
class DocumentResource extends JsonResource
|
||||
{
|
||||
// protected $userInfo;
|
||||
|
||||
// public function userInfo($resource, $userInfo = null)
|
||||
// {
|
||||
// $this->userInfo = $userInfo;
|
||||
// }
|
||||
|
||||
private static $userInfo;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -19,14 +31,23 @@ class DocumentResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
//cief todo: remove
|
||||
// Log::error('DocumentResource 1: '. json_encode(self::$userInfo));
|
||||
// Log::error('DocumentResource 2: '. json_encode($this->relationLoaded('owner')));
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'reference' => $this->reference,
|
||||
'status' => (int) $this->status,
|
||||
'document_type' => $this->document_type,
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner) : new CompanyResource($this->owner)) : null,
|
||||
'owner' => $this->relationLoaded('owner') ? ($this->owner instanceof Booking ? new BookingResource($this->owner, self::$userInfo) : new CompanyResource($this->owner, self::$userInfo)) : null,
|
||||
'files' => FileResource::collection($this->files),
|
||||
'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
}
|
||||
|
||||
public static function customResourceCollection($resource, $userInfo): AnonymousResourceCollection
|
||||
{
|
||||
self::$userInfo = $userInfo;
|
||||
return parent::collection($resource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ daemonize = no
|
||||
|
||||
[www]
|
||||
listen = 9000
|
||||
php_admin_value[max_execution_time] = 60
|
||||
|
||||
pm.max_children = 15
|
||||
pm.max_requests = 500
|
||||
|
||||
+2
-2
@@ -117,11 +117,11 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component ref="pendingOrdersList" section="pendingOrdersSection" :endpoint="route('api.transaction.list')" :options="{per_page: 5, status: 2, owner_type: 'App\\Models\\Booking', type: 1, original_currency_id_in: [selectedCurrency.id], transaction_service_id: selectedService.id}">
|
||||
<list-polling-component ref="pendingOrdersList" section="pendingOrdersSection" :endpoint="route('api.transaction.list.job')" :options="{per_page: 5, status: 2, owner_type: 'App\\Models\\Booking', type: 1, original_currency_id_in: [selectedCurrency.id], transaction_service_id: selectedService.id}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<supplier-pending-order-component :data="data" v-on:input="updateOrder($event)"></supplier-pending-order-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
console.log('ListPolling 2:', JSON.stringify(response.payload.data));
|
||||
let jobId = response.payload.data.job_id;
|
||||
if(jobId){
|
||||
this.startPolling(jobId);
|
||||
|
||||
@@ -70,11 +70,11 @@
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="paymentVerificationSection" :endpoint="route('api.transaction.list')" :options="{'payment_approvals': true}">
|
||||
<list-polling-component key="2" section="paymentVerificationSection" :endpoint="route('api.transaction.list.job')" :options="{'payment_approvals': true}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<payment-verification-component section="paymentVerificationSection" :data="data"></payment-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,11 +83,11 @@
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="listRefundTransactionSection" :endpoint="route('api.transaction.list')" :options="{'type': 6, status: 1}">
|
||||
<list-polling-component key="2" section="listRefundTransactionSection" :endpoint="route('api.transaction.list.job')" :options="{'type': 6, status: 1}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<refund-verification-component section="listRefundTransactionSection" :data="data"></refund-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,11 +180,11 @@
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component ref="paymentProofList" section="paymentProofSection" :endpoint="route('api.transaction.list')" :options="{status: 1, type: 3, issuer_not_in: [2185, 1970, 1921]}">
|
||||
<list-polling-component ref="paymentProofList" section="paymentProofSection" :endpoint="route('api.transaction.list.job')" :options="{status: 1, type: 3, issuer_not_in: [2185, 1970, 1921]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<payment-proof-component :data="data"></payment-proof-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -202,11 +202,11 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="poPendingApprovalSection" :endpoint="route('api.booking.list')" :options="{per_page: 10, purchase_order_approval: true, status_in: [2]}">
|
||||
<list-polling-component key="2" section="poPendingApprovalSection" :endpoint="route('api.booking.list.job')" :options="{per_page: 10, purchase_order_approval: true, status_in: [2]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<booking-component :data="data"></booking-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -220,11 +220,11 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="poPendingSubmissionSection" :endpoint="route('api.booking.list')" :options="{per_page: 10, pending_purchase_order: true, has_payment_status_in: [2, 3]}">
|
||||
<list-polling-component key="2" section="poPendingSubmissionSection" :endpoint="route('api.booking.list.job')" :options="{per_page: 10, pending_purchase_order: true, has_payment_status_in: [2, 3]}">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<booking-component :data="data"></booking-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -296,11 +296,11 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<list-component key="2" section="identificationVerificationSection" :options="{'per_page': 5, 'document_type_in': ['SSM_REGISTRATION', 'IDENTITY_CARD'], 'status': 1, 'with_company': true}" :endpoint="route('api.document.list')">
|
||||
<list-polling-component key="2" section="identificationVerificationSection" :options="{'per_page': 5, 'document_type_in': ['SSM_REGISTRATION', 'IDENTITY_CARD'], 'status': 1, 'with_company': true}" :endpoint="route('api.document.list.job')">
|
||||
<template slot="list" slot-scope="{data}">
|
||||
<identification-verification-component section="identificationVerificationSection" :data="data"></identification-verification-component>
|
||||
</template>
|
||||
</list-component>
|
||||
</list-polling-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::group(['prefix' => 'booking', 'as' => 'booking.', 'namespace' => 'Bookings'], function () {
|
||||
Route::get('/show/{marking}', 'FetchBookingController@fetch')->name('show');
|
||||
Route::get('/list', 'ListBookingsController@list')->name('list');
|
||||
Route::get('/list/job', 'ListBookingsJobController@list')->name('list.job');
|
||||
Route::post('/create', 'CreateBookingController@create')->name('create');
|
||||
Route::put('/update/{id}', 'UpdateBookingController@update')->name('update');
|
||||
Route::put('/cancel/{id}', 'CancelBookingController@cancel')->name('cancel');
|
||||
|
||||
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::group(['prefix' => 'transactions', 'namespace' => 'Transactions', 'as' => 'transaction.'], function () {
|
||||
|
||||
Route::get('/list', 'ListTransactionsController@list')->name('list');
|
||||
Route::get('/list/job', 'ListTransactionsJobController@list')->name('list.job');
|
||||
Route::delete('/suspend/{id}', 'SuspendTransactionController@suspend')->name('suspend');
|
||||
|
||||
route::post('/supplier/{id}/bill/create', 'CreateSupplierTransactionController@create')->name('supplier.create');
|
||||
|
||||
Reference in New Issue
Block a user