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


PHP Task::validate方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (($role = priviledge::getRole()) == 'Admin') {
         $model = new Task();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             $model->url = strtolower($model->url);
             $model->status = 'Pending';
             //$model->user_id = \Yii::$app->user->identity;
             $mode = new LoginForm();
             $mode->username = \Yii::$app->user->identity->username;
             $user = new User();
             if ($user = $mode->getUser()) {
                 $model->user_id = $user->id;
             }
             $listsocmed = $_POST['Task']['socmed'];
             $model->facebook = 'No';
             $model->twitter = 'No';
             foreach ($listsocmed as $value) {
                 if ($value == 'Facebook') {
                     $model->facebook = 'Yes';
                 }
                 if ($value == 'Twitter') {
                     $model->twitter = 'Yes';
                 }
             }
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->task_id]);
             } else {
                 return $this->render('create', ['model' => $model]);
             }
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
开发者ID:andrenovelando,项目名称:firewall-webapps,代码行数:42,代码来源:TaskController.php

示例2: actionTaskEdit

 public function actionTaskEdit()
 {
     if (isset($_GET['task_id'])) {
         $task = Task::findOne($_GET['task_id']);
     } else {
         $task = new Task();
     }
     /**
      * @var Task $task
      */
     $post = \Yii::$app->request->post();
     if ($task->load($post) && $task->validate()) {
         $task = TaskManager::editTask($task, $post['Task']['time'], $post['Task']['command'], $post['Task']['status'], $post['Task']['comment']);
         \Yii::$app->response->redirect('/?r=tasks/task-edit&task_id=' . $task->task_id);
     }
     return $this->render('task_edit', array('task' => $task, 'methods' => TaskLoader::getAllMethods(self::$tasks_controllers_folder, self::$tasks_namespace)));
 }
开发者ID:MUlt1mate,项目名称:cron-manager,代码行数:17,代码来源:TasksController.php

示例3: actionAddTask

 /**
  * Добавление задачи
  * @return string
  */
 public function actionAddTask()
 {
     if (Yii::$app->getRequest()->getQueryParam('user')) {
         $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user'));
         if (Yii::$app->getRequest()->getQueryParam('name') && Yii::$app->getRequest()->getQueryParam('description')) {
             $new_task = new Task();
             $new_task->name = Yii::$app->getRequest()->getQueryParam('name');
             $new_task->description = Yii::$app->getRequest()->getQueryParam('description');
             $new_task->status = 1;
             $new_task->source_id = 327;
             $new_task->hour = 0;
             $new_task->dead_line = 0;
             if ($new_task->validate()) {
                 if ($new_task->save()) {
                     $tasks = Task::find()->where('status = 0 or status = 1')->orderBy('id DESC')->all();
                     return $this->renderPartial('new_tasks', ['tasks_list' => $tasks, 'user' => $user]);
                 } else {
                     return $this->renderPartial('error');
                 }
             } else {
                 return 'Текст большой!';
             }
         }
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:29,代码来源:DefaultController.php


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