mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-25 07:24:21 +00:00
bulk commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?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\Classes\Modules\Addresses\DataTransferObjects\AddressObject;
|
||||
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;
|
||||
|
||||
/**
|
||||
* FetchAddressControllerLogic 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user