mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Addresses\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Addresses\Services\FetchesAddress;
|
|
use App\Classes\Modules\Addresses\Standards\Rules\CanFetchAddress;
|
|
use App\Http\Resources\AddressResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchAddressLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Address',
|
|
'message' => 'You have successfully retrieved a Address'
|
|
];
|
|
}
|
|
|
|
/** @var CanFetchAddress */
|
|
private $canFetchAddress;
|
|
|
|
/** @var FetchesAddress */
|
|
private $fetchesAddress;
|
|
|
|
/**
|
|
* FetchAddressControllersLogic constructor.
|
|
* @param CanFetchAddress $canFetchAddress
|
|
* @param FetchesAddress $fetchesAddress
|
|
*/
|
|
public function __construct(CanFetchAddress $canFetchAddress, FetchesAddress $fetchesAddress)
|
|
{
|
|
$this->canFetchAddress = $canFetchAddress;
|
|
$this->fetchesAddress = $fetchesAddress;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
$this->canFetchAddress->passes();
|
|
|
|
$query = $this->fetchesAddress->execute(['id' => $request->route('id')]);
|
|
|
|
return $this->resourceResponse(new AddressResource($query));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
} |