Issues (1256)

controllers/admin/AboutController.php (3 issues)

1
<?php
2
3
namespace app\controllers\admin;
4
5
use app\traits\{AdminBeforeActionTrait, AccessTrait};
6
use yii\web\NotFoundHttpException;
7
use app\models\{About, AboutSearch};
8
use Itstructure\AdminModule\controllers\CommonAdminController;
9
10
/**
11
 * Class AboutController
12
 * AboutController implements the CRUD actions for About model.
13
 *
14
 * @package app\controllers\admin
15
 */
16
class AboutController extends CommonAdminController
17
{
18
    use AdminBeforeActionTrait, AccessTrait;
0 ignored issues
show
The trait app\traits\AccessTrait requires the property $user which is not provided by app\controllers\admin\AboutController.
Loading history...
The trait app\traits\AdminBeforeActionTrait requires the property $controller which is not provided by app\controllers\admin\AboutController.
Loading history...
19
20
    /**
21
     * @var bool
22
     */
23
    protected $setEditingScenarios = true;
24
25
    /**
26
     * Set about record as default.
27
     *
28
     * @param $aboutId
29
     *
30
     * @return \yii\web\Response
31
     *
32
     * @throws NotFoundHttpException
33
     */
34
    public function actionSetDefault($aboutId)
35
    {
36
        if (!$this->checkAccessToUpdate()) {
37
            return $this->accessError();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->accessError() returns the type string which is incompatible with the documented return type yii\web\Response.
Loading history...
38
        }
39
40
        $about = About::findOne($aboutId);
41
42
        if (null === $about) {
43
            throw  new NotFoundHttpException('Record with id ' . $aboutId . ' does not exist');
44
        }
45
46
        $about->default = 1;
47
        $about->save();
48
49
        return $this->redirect('index');
50
    }
51
52
    /**
53
     * @return mixed|string
54
     */
55
    public function actionIndex()
56
    {
57
        if (!$this->checkAccessToIndex()) {
58
            return $this->accessError();
59
        }
60
61
        return parent::actionIndex();
62
    }
63
64
    /**
65
     * @param int|string $id
66
     *
67
     * @return mixed
68
     */
69
    public function actionView($id)
70
    {
71
        if (!$this->checkAccessToView()) {
72
            return $this->accessError();
73
        }
74
75
        return parent::actionView($id);
76
    }
77
78
    /**
79
     * @return mixed|string|\yii\web\Response
80
     */
81
    public function actionCreate()
82
    {
83
        if (!$this->checkAccessToCreate()) {
84
            return $this->accessError();
85
        }
86
87
        return parent::actionCreate();
88
    }
89
90
    /**
91
     * @param int|string $id
92
     *
93
     * @return string|\yii\web\Response
94
     */
95
    public function actionUpdate($id)
96
    {
97
        if (!$this->checkAccessToUpdate()) {
98
            return $this->accessError();
99
        }
100
101
        return parent::actionUpdate($id);
102
    }
103
104
    /**
105
     * @param int|string $id
106
     *
107
     * @return mixed|\yii\web\Response
108
     */
109
    public function actionDelete($id)
110
    {
111
        if (!$this->checkAccessToDelete()) {
112
            return $this->accessError();
113
        }
114
115
        return parent::actionDelete($id);
116
    }
117
118
    /**
119
     * Returns About model name.
120
     *
121
     * @return string
122
     */
123
    protected function getModelName():string
124
    {
125
        return About::class;
126
    }
127
128
    /**
129
     * Returns AboutSearch model name.
130
     *
131
     * @return string
132
     */
133
    protected function getSearchModelName():string
134
    {
135
        return AboutSearch::class;
136
    }
137
}
138