Files
exchange-2.0/app/Classes/Modules/Currencies/ControllersLogic/ListCurrencyLogic.php
T
CheeSiong 1dfb75545f List Currency Rate Logic Class
Fetch Currency Rate Logic Class
 Create Currency Rate Logic Class
 Update Currency Rate Logic Class
Currency Rate Converter Rate
2020-12-30 08:47:12 +08:00

66 lines
1.7 KiB
PHP

<?php
namespace App\Classes\Modules\Currencies\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllersLogic;
use App\Classes\Modules\Currencies\Services\ListsCurrency;
use App\Classes\Modules\Currencies\Standards\Rules\CanListCurrency;
use App\Http\Resources\CurrencyResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListCurrencyLogic extends AbstractControllersLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Currency',
'message' => 'You have successfully retrieved a list of Currency'
];
}
/** @var CanListCurrency */
private $canListCurrency;
/** @var ListsCurrency */
private $listsCurrency;
/**
* ListCurrencyLogic constructor.
* @param CanListCurrency $canListCurrency
* @param ListsCurrency $listsCurrency
*/
public function __construct(CanListCurrency $canListCurrency, ListsCurrency $listsCurrency)
{
$this->canListCurrency = $canListCurrency;
$this->listsCurrency = $listsCurrency;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canListCurrency->passes();
$query = $this->listsCurrency->execute();
return $this->collectionResponse(CurrencyResource::collection($query));
} catch (\Exception $exception){
dd($exception);
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}