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.
 
 
 

67 lines
1.6 KiB

<?php
namespace api\controllers;
use api\logic\Helper;
use backend\modules\shop\models\ars\Collection;
use Throwable;
use Yii;
/**
* @author iron
* @email weiriron@gmail.com
*/
class CollectionController extends CommonController
{
public $modelClass = 'backend\modules\shop\models\ars\Collection';
public $className = 'api\logic\CollectionLogic';
public function actions()
{
$action = parent::actions();
unset($action['delete']);
unset($action['view']);
$action['options'] = [
'class' => 'yii\rest\OptionsAction',
'collectionOptions' => ['DELETE', 'PUT', 'OPTIONS']
];
return $action;
}
/**
* @return object
* @throws yii\base\InvalidConfigException
*/
public function actionIndex()
{
$query = Collection::find()->where(['user_id' => Yii::$app->user->getId()]);
return Helper::index($query);
}
/**
* @return bool
* @throws Yii\base\InvalidConfigException
* @throws Yii\db\StaleObjectException
* @throws Throwable
* @throws yii\base\Exception
* @throws yii\web\BadRequestHttpException
* @throws yii\web\NotFoundHttpException
* @throws yii\web\ServerErrorHttpException
*/
public function actionUpdate()
{
return $this->object->update();
}
/**
* @throws Throwable
* @throws Yii\db\StaleObjectException
* @throws yii\web\BadRequestHttpException
* @throws yii\web\NotFoundHttpException
* @throws yii\web\ServerErrorHttpException
*/
public function actionDelete()
{
return $this->object->delete();
}
}