當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Activity::load方法代碼示例

本文整理匯總了PHP中app\models\Activity::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Activity::load方法的具體用法?PHP Activity::load怎麽用?PHP Activity::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Activity的用法示例。


在下文中一共展示了Activity::load方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionCreate

 public function actionCreate()
 {
     $activity = new Activity();
     if ($activity->load(Yii::$app->request->post()) && $activity->save()) {
         $activities = Activity::find()->where(['belong_to' => $this->data_post['belong_to']])->orderBy('id DESC')->limit(5)->offset(0)->all();
         $this->data_post = array_merge($this->data_post, ['activities' => $activities]);
         return ['errors' => '', 'data' => $this->renderPartial('@widget/views/activities/_list', $this->data_post)];
     }
 }
開發者ID:hoangngk,項目名稱:adminpanel,代碼行數:9,代碼來源:ActivitiesController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Activity();
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         //var_dump($model->getErrors()); die;
     }
     return $this->render('create', array('model' => $model));
 }
開發者ID:rahaldr,項目名稱:hello-world,代碼行數:9,代碼來源:ActivityController.php

示例3: actionCreate

 /**
  * Creates a new Activity model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Activity();
     if (Yii::$app->session->has('program_id')) {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new \yii\web\NotFoundHttpException();
     }
 }
開發者ID:HazimAnas,項目名稱:point-tracker,代碼行數:18,代碼來源:ActivityController.php

示例4: actionCreate

 /**
  * Creates a new Activity model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Activity();
     if ($model->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         //$model->date = Yii::$app->formatter->asDate('today', 'long');
         $model->created_at = date('Y-m-d h:i:s');
         if ($model->save()) {
             Yii::$app->notification->notify($model->title, $model, Yii::$app->user->identity, Yii::$app->controller->id, '*');
             Yii::$app->session->setFlash('success', 'Activity posted successfully.');
             return $this->redirect(['index']);
         }
     } else {
         if (Yii::$app->request->isAjax) {
             return $this->renderAjax('_form', ['model' => $model]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }
開發者ID:livingdreams,項目名稱:kidcrossing,代碼行數:25,代碼來源:ActivityController.php

示例5: actionCreate

 /**
  * Creates a new Activity model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Activity();
     if (Yii::$app->request->isPost) {
         $postInfo = Yii::$app->request->post();
         if (strtotime($postInfo['Activity']['end_time']) <= strtotime($postInfo['Activity']['begin_time'])) {
             throw new ServerErrorHttpException('更新狀態失敗,原因:開始時間不能大於結束時間!');
         }
         if (strtotime($postInfo['Activity']['sign_up_end_time']) <= strtotime($postInfo['Activity']['sign_up_begin_time'])) {
             throw new ServerErrorHttpException('更新狀態失敗,原因:注冊開始時間不能大於注冊結束時間!');
         }
         if (strtotime($postInfo['Activity']['begin_time']) <= strtotime($postInfo['Activity']['sign_up_end_time'])) {
             throw new ServerErrorHttpException('更新狀態失敗,原因:注冊結束時間不能大於開始時間!');
         }
         $postInfo['Activity']['code'] = date('Ymd', time());
         if ($model->load($postInfo) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             throw new ServerErrorHttpException('更新狀態失敗,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE) . '!');
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
開發者ID:hanxiao84322,項目名稱:coach_system,代碼行數:29,代碼來源:ActivityController.php

示例6: actionCreate

 /**
  * Creates a new Activity model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('activityCreate')) {
         $model = new Activity();
         if ($model->load(Yii::$app->request->post())) {
             $model->lastModifyTime = date("Y-m-d H:i:s");
             $model->Administrator_id = Yii::$app->user->id;
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
         return $this->render('create', ['model' => $model]);
     } else {
         if (Yii::$app->user->isGuest) {
             Yii::$app->user->loginRequired();
         } else {
             throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
         }
     }
 }
開發者ID:pyw5pkU9PcdW,項目名稱:COMP3421,代碼行數:25,代碼來源:ActivityController.php


注:本文中的app\models\Activity::load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。