mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
66 lines
1.7 KiB
PHP
66 lines
1.7 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\Documents\Standards\Rules\CanListDocuments;
|
|
use App\Http\Resources\DocumentResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ListDocumentLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Document',
|
|
'message' => 'You have successfully retrieved a list of Document'
|
|
];
|
|
}
|
|
|
|
/** @var CanListDocuments */
|
|
private $canListDocuments;
|
|
|
|
/** @var ListsDocuments */
|
|
private $listsDocuments;
|
|
|
|
/**
|
|
* ListStandardSegmentLogic constructor.
|
|
* @param CanListDocuments $canListDocuments
|
|
* @param ListsDocuments $listsDocuments
|
|
*/
|
|
public function __construct(CanListDocuments $canListDocuments, ListsDocuments $listsDocuments)
|
|
{
|
|
$this->canListDocuments = $canListDocuments;
|
|
$this->listsDocuments = $listsDocuments;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
$this->canListDocuments->passes();
|
|
|
|
$query = $this->listsDocuments->execute($this->listsDocuments->deserializeFilters($request->input('filters')));
|
|
|
|
return $this->collectionResponse(DocumentResource::collection($query));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
} |