Issues (1256)

controllers/admin/SettingController.php (3 issues)

1
<?php
2
3
namespace app\controllers\admin;
4
5
use Yii;
6
use app\traits\{AdminBeforeActionTrait, AccessTrait};
7
use Itstructure\AdminModule\controllers\AdminController;
8
9
/**
10
 * Class SettingController
11
 * SettingController implements the CRUD actions for Setting model.
12
 *
13
 * @package app\controllers\admin
14
 */
15
class SettingController extends AdminController
16
{
17
    use AdminBeforeActionTrait, AccessTrait;
0 ignored issues
show
The trait app\traits\AdminBeforeActionTrait requires the property $controller which is not provided by app\controllers\admin\SettingController.
Loading history...
The trait app\traits\AccessTrait requires the property $user which is not provided by app\controllers\admin\SettingController.
Loading history...
18
19
    /**
20
     * List of records.
21
     *
22
     * @return string
23
     */
24
    public function actionIndex()
25
    {
26
        if (!$this->checkAccessToAdministrate()) {
27
            return $this->accessError();
28
        }
29
30
        /* @var $model \app\models\Setting */
31
        $model = Yii::$app->get('settings')
32
            ->setModel()
33
            ->getSettings();
34
35
        if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post()) && $model->save()) {
36
            return $this->redirect([
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->redirect(array('/admin/settings')) returns the type yii\web\Response which is incompatible with the documented return type string.
Loading history...
37
                '/admin/settings'
38
            ]);
39
        }
40
41
        $fields = [
42
            'model' => $model,
43
            'roles' => Yii::$app->authManager->getRoles()
44
        ];
45
46
        return $this->render('index', $fields);
47
    }
48
}
49