You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

  1. <?php
  2. namespace api\controllers;
  3. use api\logic\Helper;
  4. use backend\modules\shop\models\ars\Address;
  5. use Yii;
  6. use Throwable;
  7. use yii\web\NotFoundHttpException;
  8. /**
  9. * @author iron
  10. * @email weiriron@gmail.com
  11. */
  12. class AddressController extends CommonController
  13. {
  14. public $modelClass = 'backend\modules\shop\models\ars\Address';
  15. public $className = 'api\logic\AddressLogic';
  16. /**
  17. * @return object
  18. * @throws yii\base\InvalidConfigException
  19. */
  20. public function actionIndex()
  21. {
  22. $query = Address::find()->where(['user_id' => Yii::$app->user->getId()]);
  23. return Helper::index($query);
  24. }
  25. /**
  26. * @return bool
  27. * @throws NotFoundHttpException
  28. * @throws Yii\base\InvalidConfigException
  29. * @throws Yii\db\StaleObjectException
  30. * @throws Throwable
  31. * @throws yii\base\Exception
  32. * @throws yii\web\BadRequestHttpException
  33. * @throws yii\web\ServerErrorHttpException
  34. */
  35. public function actionUpdate()
  36. {
  37. return $this->object->update();
  38. }
  39. /**
  40. * @return Address|null
  41. * @throws NotFoundHttpException
  42. * @throws yii\base\Exception
  43. * @throws yii\web\BadRequestHttpException
  44. * @throws yii\web\ServerErrorHttpException
  45. */
  46. public function actionCreate()
  47. {
  48. return $this->object->create();
  49. }
  50. }