當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。