| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace backendApi\modules\v1\controllers;
- use common\helpers\Form;
- use common\models\Currency;
- use common\models\CurrencyConversions;
- use common\models\forms\CurrenciesConversionsForm;
- use common\models\forms\FreeTemplateForm;
- use common\models\FreeTemplate;
- use yii\db\Exception;
- use yii\web\HttpException;
- class TransportationController extends BaseController
- {
- public $modelClass = FreeTemplate::class;
- public function actionTransportationList()
- {
- $data = $this->modelClass::getFromCache();
- return static::notice(['data' => $data]);
- }
- public function actionSetTransportation()
- {
- if (\Yii::$app->request->isPost) {
- $formModel = new FreeTemplateForm();
- $formModel->scenario = 'setTransportation';
- if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->setTransportation()) {
- // 更新缓存
- $this->modelClass::updateToCache();
- return static::notice(\Yii::t('ctx', 'successfully'));
- } else {
- return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
- }
- }
- return static::notice(\Yii::t('ctx', 'illegalRequest'));
- }
- }
|