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

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
127
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Worker model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Worker the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
public static function findModel($id)
{
if (($model = Worker::findOne($id)) !== null) {
return $model;
}
128
throw new NotFoundHttpException(Yii::t('app', 'The requested page does
not exist.'));
}
}
<?php
namespace app\controllers;
use Yii;
use app\models\WorkTime;
use app\models\WorkTimeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* WorkTimeController implements the CRUD actions for WorkTime model.
*/
class WorkTimeController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
129
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' =>
[
[
'actions' => ['index', 'view', 'create',
'update', 'delete'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
130
],
];
}
/**
* Lists all WorkTime models.
* @return mixed
*/
public function actionIndex($id_worker)
{
$worker = WorkerController::findModel($id_worker);
$searchModel = new WorkTimeSearch();
$dataProvider = $searchModel->search(Yii::$app->request-
>queryParams);
$dataProvider->query->andWhere(['id_worker' => $worker->id]);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'worker' => $worker,
]);
}
131
/**
* Displays a single WorkTime model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
$model = $this->findModel($id);
$worker = WorkerController::findModel($model->id_worker);
return $this->render('view', [
'model' => $model,
'worker' => $worker,
]);
}
/**
* Creates a new WorkTime model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id_worker)
{
Источник: https://baza.diplomsite.ru/previewfile/2451