Дипломная работа: Автоматизация учета рабочего времени сотрудников МБОУДО "ДДЮТ"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
122
Приложение. Листинг программного модуля
<?php
namespace app\controllers;
use Yii;
use app\models\Worker;
use app\models\WorkerSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* WorkerController implements the CRUD actions for Worker model.
*/
class WorkerController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
123
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' =>
[
[
'actions' => ['index', 'view', 'create',
'update', 'delete'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
124
}
/**
* Lists all Worker models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new WorkerSearch();
$dataProvider = $searchModel->search(Yii::$app->request-
>queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Worker model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
125
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Worker model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Worker();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
126
/**
* Updates an existing Worker model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
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,
]);
}
/**
* Deletes an existing Worker model.
* If deletion is successful, the browser will be redirected to the 'index' page.
Источник: https://baza.diplomsite.ru/previewfile/2451