Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionIndex()
- {
- $lessons = Events::find()->all();
- foreach ($lessons as $lesson)
- {
- $time = Timetable::findOne($lesson->timetable_id);
- $event = new Event();
- $event->id = $lesson->id;
- $event->title = $lesson->topic;
- $event->start = $lesson->date . 'T' . $time->start;
- $event->end = $lesson->date . 'T' . $time->finish;
- $events[] = $event;
- }
- return $this->render('index', [
- 'events' => $events
- ]);
- }
- /**
- * Displays a single Events model.
- * @param integer $id
- * @return mixed
- */
- public function actionView($id)
- {
- return $this->renderAjax('view', [
- 'model' => $this->findModel($id),
- ]);
- }
- /**
- * Creates a new Events model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @param $date
- * @return mixed
- */
- public function actionCreate($date)
- {
- $model = new Events();
- $model->date = $date;
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['/events']);
- } else {
- return $this->renderAjax('create', [
- 'model' => $model,
- ]);
- }
- }
- /**
- * Updates an existing Events model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect('/web/events');
- } else {
- return $this->renderAjax('update', [
- 'model' => $model,
- ]);
- }
- }
- /**
- * Deletes an existing Events model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
- return $this->redirect(['/events']);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement