2023-06-11 12:14:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Currency\Http\Controllers\Admin;
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
use Illuminate\Http\Response;
|
2023-06-11 12:14:03 +00:00
|
|
|
use Modules\Admin\Traits\HasCrudActions;
|
|
|
|
use Modules\Currency\Entities\CurrencyRate;
|
|
|
|
use Modules\Currency\Services\CurrencyRateExchanger;
|
|
|
|
use Modules\Currency\Http\Requests\UpdateCurrencyRateRequest;
|
|
|
|
|
|
|
|
class CurrencyRateController
|
|
|
|
{
|
|
|
|
use HasCrudActions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Model for the resource.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = CurrencyRate::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Label of the resource.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $label = 'currency::currency_rates.currency_rate';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View path of the resource.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $viewPath = 'currency::admin.currency_rates';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form requests for the resource.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $validation = UpdateCurrencyRateRequest::class;
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
|
|
|
* Refresh currency rates.
|
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @param CurrencyRateExchanger $exchanger
|
|
|
|
*
|
|
|
|
* @return Response
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
|
|
|
public function refresh(CurrencyRateExchanger $exchanger)
|
|
|
|
{
|
|
|
|
if (is_null(setting('currency_rate_exchange_service'))) {
|
|
|
|
abort(400, trans('currency::messages.exchange_service_is_not_configured'));
|
|
|
|
}
|
|
|
|
|
|
|
|
CurrencyRate::refreshRates($exchanger);
|
|
|
|
}
|
|
|
|
}
|