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
Bug
introduced
by
![]() |
|||
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
|
|||
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 |