/
qwazarr
/
EducationalPractice
Обзор
Документация
Войти
/
qwazarr
/
EducationalPractice
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
modules/admin/controllers/LessonTopicController.php
105 строк
2 KB
qwazarr
'Расписание'
28 июн 2026, 17:12
28 июн 2026, 17:12
9d84635
Код
Авторство
О чём код?
<?php namespace app\modules\admin\controllers; use app\models\LessonTopic; use app\models\LessonTopicSearch; use Yii; use yii\filters\AccessControl; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; class LessonTopicController extends Controller { public function behaviors() { return [ 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['POST'], ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], ] ] ] ]; } public function actionIndex() { $searchModel = new LessonTopicSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } public function actionView($id) { return $this->render('view', [ 'model' => $this->findModel($id), ]); } public function actionCreate() { $model = new LessonTopic(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'id' => $model->id]); } return $this->render('create', [ 'model' => $model, ]); } public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } return $this->render('update', [ 'model' => $model, ]); } public function actionDelete($id) { $this->findModel($id)->delete(); return $this->redirect(['index']); } public function actionUpdateStatus() { $id = Yii::$app->request->post('id'); $isDone = Yii::$app->request->post('is_done'); $model = $this->findModel($id); $model->is_done = $isDone; $model->save(); } protected function findModel($id) { if (($model = LessonTopic::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); } }