mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
76 lines
2.1 KiB
PHP
76 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Documents\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\Modules\Documents\Services\ListsDocuments;
|
|
use App\Classes\Modules\Documents\Standards\Rules\CanListDocuments;
|
|
use App\Http\Resources\DocumentResource;
|
|
use App\Models\Document;
|
|
use App\Transformers\DocumentTransformer;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use League\Fractal;
|
|
|
|
|
|
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 AccessForbiddenException
|
|
* @throws MalformedRequestException
|
|
* @throws RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
|
|
$this->canListDocuments->passes();
|
|
|
|
$query = $this->listsDocuments->execute(array_merge($this->listsDocuments->deserializeFilters($request->input('filters')), ['with_owner' => true]));
|
|
|
|
return $this->collectionResponse(DocumentResource::collection($query));
|
|
|
|
|
|
/* return fractal()
|
|
->collection($query, new DocumentTransformer)
|
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
|
|
}
|
|
|
|
}
|