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.

48 lines
1.0 KiB

  1. <?php
  2. namespace api\controllers;
  3. use api\logic\Helper;
  4. use backend\modules\shop\models\ars\Comment;
  5. use Yii;
  6. /**
  7. * @author iron
  8. * @email weiriron@gmail.com
  9. */
  10. class CommentController extends CommonController
  11. {
  12. public $modelClass = 'backend\modules\shop\models\ars\Comment';
  13. public $className = 'api\logic\CommentLogic';
  14. public function actions()
  15. {
  16. $action = parent::actions();
  17. unset($action['view']);
  18. return $action;
  19. }
  20. /**
  21. * @return object
  22. * @throws yii\base\InvalidConfigException
  23. */
  24. public function actionIndex()
  25. {
  26. $query = Comment::find()->where(['user_id' => Yii::$app->user->getId()]);
  27. return Helper::index($query);
  28. }
  29. /**
  30. * @return array|Comment|null
  31. * @throws yii\base\Exception
  32. * @throws yii\web\BadRequestHttpException
  33. * @throws yii\web\NotFoundHttpException
  34. * @throws yii\web\ServerErrorHttpException
  35. */
  36. public function actionCreate()
  37. {
  38. return $this->object->create();
  39. }
  40. }