mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-21 05:24:01 +00:00
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\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\Companies\Services\ListsCompanies;
|
|
use App\Classes\Modules\Companies\Standards\Rules\CanListCompanies;
|
|
use App\Transformers\CompanyTransformer;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Fractalistic\ArraySerializer;
|
|
|
|
class ListCompaniesLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Companies',
|
|
'message' => 'You have successfully retrieved a list of Companies'
|
|
];
|
|
}
|
|
|
|
/** @var CanListCompanies */
|
|
private $canListCompanies;
|
|
|
|
/** @var ListsCompanies */
|
|
private $listsCompanies;
|
|
|
|
/**
|
|
* ListCompaniesControllersLogic constructor.
|
|
* @param CanListCompanies $canListCompanies
|
|
* @param ListsCompanies $listsCompanies
|
|
*/
|
|
public function __construct(CanListCompanies $canListCompanies, ListsCompanies $listsCompanies)
|
|
{
|
|
$this->canListCompanies = $canListCompanies;
|
|
$this->listsCompanies = $listsCompanies;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws AccessForbiddenException
|
|
* @throws MalformedRequestException
|
|
* @throws RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canListCompanies->passes();
|
|
|
|
$query = $this->listsCompanies->execute($this->listsCompanies->deserializeFilters($request->input('filters')));
|
|
// return $this->collectionResponse(CompanyResource::collection($query));
|
|
|
|
return fractal()
|
|
->parseIncludes(['owner'])
|
|
->collection($query, new CompanyTransformer(), "data")
|
|
->serializeWith(new ArraySerializer())
|
|
->respond(200, [], JSON_PRETTY_PRINT);
|
|
|
|
|
|
|
|
}
|
|
|
|
} |