当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::validate方法代码示例

本文整理汇总了PHP中app\models\Event::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::validate方法的具体用法?PHP Event::validate怎么用?PHP Event::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Event的用法示例。


在下文中一共展示了Event::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testValidateCorrect

 public function testValidateCorrect()
 {
     $model = new Event(['type' => 'Type', 'name' => 'Name', 'event' => 'Event', 'title' => 'Title']);
     $this->specify('event wrong', function () use($model) {
         expect('model should not validate', $model->validate())->true();
     });
 }
开发者ID:vitalik74,项目名称:event-app,代码行数:7,代码来源:EventTest.php

示例2: actionEvents

 /**
  * Добавление события
  * @return string
  */
 public function actionEvents()
 {
     if (Yii::$app->getRequest()->getQueryParam('user')) {
         $start_day = strtotime('now 00:00:00', time() + 7 * 60 * 60);
         $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user'));
         if (!$user) {
             return 'Доступ запрещен!';
         }
         if (Yii::$app->getRequest()->getQueryParam('text') && Yii::$app->getRequest()->getQueryParam('cat')) {
             if (Categories::find()->where("name like '" . trim(Yii::$app->getRequest()->getQueryParam('cat') . "'"))->one()) {
                 $cat_id = Categories::find()->where(['name' => Yii::$app->getRequest()->getQueryParam('cat')])->one()->id;
                 //$item->cat_id = Categories::find()->where("name like '".trim(Yii::$app->getRequest()->getQueryParam('cat')."'"))->one()->id;
             } else {
                 return "Категория!";
             }
             $act = new DiaryActs();
             $act->model_id = 10;
             $act->user_id = $user->id;
             //return var_dump($act);
             if ($act->save(false)) {
                 $event = new Event();
                 $event->act_id = $act->id;
                 $event->cat_id = $cat_id;
                 if (Yii::$app->getRequest()->getQueryParam('old_data_ev')) {
                     $event->old_data = Yii::$app->getRequest()->getQueryParam('old_data_ev');
                 }
                 $event->user_id = $act->user_id;
                 $event->text = Yii::$app->getRequest()->getQueryParam('text');
                 if (!$event->validate()) {
                     return 'Данные введены некорректно';
                 } else {
                     if ($event->save()) {
                         return "<p>Событие сохранено!</p>";
                     } else {
                         return 'Ошибка сохранения';
                     }
                 }
             }
         }
         $today_event_acts = implode(',', ArrayHelper::map(DiaryActs::find()->where("time > {$start_day} and user_id = " . $user->id . " and model_id = 10")->all(), 'id', 'id'));
         $today_event = [];
         //return var_dump($today_event_acts);
         if ($today_event_acts) {
             $today_event = Event::find()->where("act_id  IN (" . $today_event_acts . ")")->orderBy('id DESC')->andWhere(["old_data" => 0])->all();
         }
         //return var_dump($today_event);
         return $this->renderPartial('add_event', ['user' => $user, 'today_event' => $today_event]);
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:53,代码来源:DefaultController.php


注:本文中的app\models\Event::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。