当前位置: 首页>>代码示例>>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;未经允许,请勿转载。