NotifyController.php 912 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: NODELOG
  5. * DateTime: 2017/3/8 17:16
  6. * Description:
  7. */
  8. namespace api\modules\v1\controllers;
  9. use api\common\controllers\Controller;
  10. use api\modules\v1\models\Notify;
  11. use yii\data\ActiveDataProvider;
  12. use api\common\behaviors\QueryParamAuth;
  13. use yii\helpers\ArrayHelper;
  14. class NotifyController extends Controller
  15. {
  16. public function behaviors()
  17. {
  18. return ArrayHelper::merge(parent::behaviors(), [
  19. [
  20. 'class' => QueryParamAuth::className(),
  21. 'tokenParam' => 'token',
  22. ]
  23. ]);
  24. }
  25. public function actionIndex()
  26. {
  27. return new ActiveDataProvider([
  28. 'query' => Notify::find()->where(['to_uid' => \Yii::$app->user->id]),
  29. 'sort' => [
  30. 'defaultOrder' => [
  31. 'id' => SORT_DESC
  32. ]
  33. ]
  34. ]);
  35. }
  36. }