mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
75 lines
2.0 KiB
PHP
75 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Documents\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Documents\Services\ListsDocuments;
|
|
use App\Classes\Modules\Generic\DataTransferObjects\ListGenericJobObject;
|
|
use App\Classes\Jobs\ListDocuments;
|
|
use App\Http\Resources\DocumentResource;
|
|
use ErrorException;
|
|
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
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'List Document Job',
|
|
'message' => 'You have successfully submit a job to list documents'
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @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(
|
|
$request->fullUrl(),
|
|
$request->all(),
|
|
$jobId,
|
|
$userInfo
|
|
);
|
|
|
|
ListDocuments::dispatch($listGenericJobObject);
|
|
|
|
//cief todo: remove comments
|
|
// // Create your job instance with delay, so we can back here within delay and take control in our hands.
|
|
// $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
|
|
// // $jobId = $this->custom_dispatch($job);
|
|
|
|
|
|
$result = [];
|
|
$result['job_id'] = $jobId;
|
|
|
|
return $this->response(['data' => $result]);
|
|
}
|
|
|
|
//cief todo: no longer need jobId
|
|
// function custom_dispatch($job): int {
|
|
// return app(\Illuminate\Contracts\Bus\Dispatcher::class)->dispatch($job);
|
|
// }
|
|
}
|