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