62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
use app\models\Store;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\modules\admin\models\comment\CommentActionForm;
|
|
use app\modules\admin\models\comment\CommentListForm;
|
|
|
|
class CommentController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function actionIndex()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new CommentListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
if(\Yii::$app->admin->identity->user->store){
|
|
$form->store_id = \Yii::$app->admin->identity->user->store->id;
|
|
}
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all();
|
|
return $this->render('index',[
|
|
'store' => $store,
|
|
]);
|
|
}
|
|
|
|
public function actionDelete()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
$form = new CommentActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |