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


PHP Task::save方法代码示例

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


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

示例1: get

 function get($criteria = null, $order = null)
 {
     $sql = "SELECT tasks.*, CONCAT(users.first_name, ' ', users.last_name) AS assigned_to_name\n                FROM tasks\n                LEFT JOIN users ON users.id = tasks.assigned_to";
     if (isset($criteria) && is_numeric($criteria)) {
         $sql .= " WHERE tasks.id = {$criteria}";
         $task = parent::get_one($sql);
         $this->update_status();
         return $task;
     } else {
         $sql = $this->add_criteria($sql, $criteria);
         $sql = $this->modify_sql_for_user_type($sql);
         $sql = $this->add_order_by($sql, $order);
         $tasks = parent::get($sql);
         foreach ($tasks as &$task) {
             //create the invoice
             $task_object = new Task($task);
             //todo: i don't think this makes any sense because the invoice status will already be updated when I create the invoice using new Invoice
             //store the current task status as it exists in the database
             $old_status = $task_object->status_text;
             //update the task status
             $task_object->update_status();
             //if the old status and the new status do not match, then we need to save this task back to the database.
             if ($old_status != (string) $task_object->status_text) {
                 //todo:make sure this isn't saving each time
                 $task_object->save(false);
             }
             //we need to add the status text back the task array, since we're sending the array to the client,
             //not the object
             $task['status_text'] = $task_object->status_text;
         }
         return $tasks;
     }
 }
开发者ID:neevan1e,项目名称:Done,代码行数:33,代码来源:task.php

示例2: after

 public function after()
 {
     echo "after\n";
     $insert = 0;
     // 判断是否插入表
     $class_name = get_class($this);
     $type = str_replace('Event', '', $class_name);
     $task = new Task();
     if ($this->event_rs['err_no'] > 0) {
         //  代表错误
         $task->is_success = 0;
         $this->event_rs['class'] = $this->class;
         $this->event_rs['param'] = $this->param;
         if ($this->retry_cnt >= 3) {
             $insert = 1;
         }
     } else {
         $task->is_success = 1;
         $insert = 1;
     }
     // 成功则入库 第一次失败则不入库 第三次失败才一起入库
     $task->create_time = time();
     $task->retry_cnt = $this->retry_cnt;
     $task->event = $type;
     $task->param = json_encode($this->param);
     if ($insert > 0) {
         $task->save();
     }
     $this->event_rs['retry_cnt'] = $this->retry_cnt;
 }
开发者ID:hytzxd,项目名称:swoole-doc,代码行数:30,代码来源:EventBase.php

示例3: store

 /**
  * Store a newly created resource in storage.
  * POST /task
  *
  * @return Response
  */
 public function store()
 {
     // Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, Task::$rules);
     if ($validation->passes()) {
         $task = new Task();
         $task->task = strtoupper(Input::get('task'));
         $task->description = strtoupper(Input::get('description'));
         $task->save();
         $id = $task->id;
         $gettime = time() - 14400;
         $datetime_now = date("H:i:s", $gettime);
         $task_approver = Input::get('task_approver');
         $task_receiver = Input::get('task_receiver');
         foreach ($task_approver as $row_approver) {
             DB::table('task_approver')->insert(array(['task_id' => $id, 'user_id' => $row_approver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
         }
         foreach ($task_receiver as $row_receiver) {
             DB::table('task_receiver')->insert(array(['task_id' => $id, 'user_id' => $row_receiver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
         }
         return Redirect::route('task.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('task.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
开发者ID:jcyanga28,项目名称:project-reference,代码行数:32,代码来源:TaskController.php

示例4: actionCreate

 public function actionCreate()
 {
     switch ($_GET['model']) {
         case 'user':
             $model = new User('create');
             break;
         case 'task':
             $model = new Task();
             break;
         default:
             $this->_sendResponse(501, Yii::t('tasklist', 'Mode "create" is not implemented for model "{model}"', array('{model}' => $_GET['model'])));
             exit;
     }
     foreach ($_POST as $var => $value) {
         if ($model->hasAttribute($var)) {
             $model->{$var} = $value;
         } else {
             $this->_sendResponse(500, Yii::t('tasklist', 'Parameter "{param}" is not allowed', array('{param}' => $var)));
         }
     }
     if ($model->save()) {
         $this->_sendResponse(200, CJSON::encode($model->attributes));
     } else {
         $this->_sendResponse(500, CJSON::encode($model->errors));
     }
 }
开发者ID:rafaelmaza,项目名称:task-list,代码行数:26,代码来源:ApiController.php

示例5: testKanbanItemSave

 public function testKanbanItemSave()
 {
     $accounts = Account::getByName('anAccount');
     $user = UserTestHelper::createBasicUser('Billy');
     $task = new Task();
     $task->name = 'MyTask';
     $task->owner = $user;
     $task->requestedByUser = $user;
     $task->description = 'my test description';
     $taskCheckListItem = new TaskCheckListItem();
     $taskCheckListItem->name = 'Test Check List Item';
     $task->checkListItems->add($taskCheckListItem);
     $task->activityItems->add($accounts[0]);
     $task->status = Task::STATUS_IN_PROGRESS;
     $this->assertTrue($task->save());
     $this->assertEquals(1, KanbanItem::getCount());
     $id = $task->id;
     unset($task);
     $task = Task::getById($id);
     //KanbanItem is created after saving Task
     $kanbanItems = KanbanItem::getAll();
     $this->assertCount(1, $kanbanItems);
     $kanbanItem = $kanbanItems[0];
     $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:25,代码来源:KanbanItemTest.php

示例6: store

 public static function store()
 {
     self::check_logged_in();
     $params = $_POST;
     if (empty($_POST['projects'])) {
         $errors[] = 'Select at least one project!';
         $projects = '';
     } else {
         $projects = $_POST['projects'];
     }
     $attributes = array('description' => $params['description'], 'priority' => $params['priority'], 'status' => 0, 'projectids' => $projects);
     $task = new Task($attributes);
     //$errors = $task->errors(); // Deprecated: Switched to valitron. Calls all validators
     $errors = $task->validateTask();
     // Valitron takes care of putting all errors in one array
     //Kint::dump($params); // Debug, comment out Redirect if used!
     //Kint::dump($task);
     if (count($errors) == 0) {
         $task->save();
         // Tell task-model to save this object to DB
         foreach ($projects as $project) {
             Project::addTask($task->id, $project);
             // We don't know the id before it is saved!
             Project::updateCount($project);
         }
         Redirect::to('/task/' . $task->id, array('message' => 'Task added to database!'));
     } else {
         Kint::dump($errors);
         $projects = Project::all();
         Kint::dump($attributes);
         Kint::dump($projects);
         View::make('task/new.html', array('errors' => $errors, 'attributes' => $attributes, 'projects' => $projects));
     }
 }
开发者ID:rubinju,项目名称:Todolist,代码行数:34,代码来源:tasks_controller.php

示例7: User

 function uncomplete_task()
 {
     $id = $this->input->post('id');
     $user = new User();
     $task = new Task();
     if ($task->where('user_id', $this->dx_auth->get_user_id())->where('id', $id)->count() == 0) {
         return;
     }
     $task->get_by_id($id);
     $task->completed = 0;
     $task->save();
     $docket = new Docket();
     $docket->get_by_id($task->docket_id);
     $task->clear();
     if ($task->where('docket_id', $docket->id)->where('completed', 0)->count() == 0) {
         $docket->completed = 1;
         $docket->save();
     } else {
         $docket->completed = 0;
         $docket->save();
     }
     $gold = $this->treasure->decrease($this->dx_auth->get_user_id());
     $task->clear();
     $task->get_by_id($id);
     $result = array('id' => $task->id, 'name' => $task->name, 'docket_id' => $docket->id, 'due' => $task->due, 'gold' => $gold);
     echo json_encode($result);
 }
开发者ID:narendranag,项目名称:dockets,代码行数:27,代码来源:ajax.php

示例8: store

 public static function store()
 {
     parent::check_logged_in();
     // POST-pyynnön muuttujat sijaitsevat $_POST nimisessä assosiaatiolistassa
     $params = $_POST;
     // Alustetaan uusi task-luokan olion käyttäjän syöttämillä arvoilla
     /*$task = new task(array(
       'name' => $params['name'],
       'description' => $params['description'],
       'publisher' => $params['publisher'],
       'published' => $params['published']
       ));*/
     $params['user_id'] = parent::get_user_logged_in()->id;
     $task = new Task($params);
     $errors = $task->validate();
     if (!$errors) {
         // Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
         $task->save();
         // Ohjataan käyttäjä lisäyksen jälkeen pelin esittelysivulle
         //Redirect::to('/task/' . $task->id, array('message' => 'Task has been added!'));
         Redirect::to('/task', array('message' => 'Task has been added!'));
     } else {
         View::make('task/new.html', array('errors' => $errors, 'attributes' => $params, 'title' => 'new task'));
     }
 }
开发者ID:tuureilmarinen,项目名称:tsoha,代码行数:25,代码来源:task_controller.php

示例9: addTask

 public function addTask()
 {
     if ($_POST) {
         // Lets start validation
         // validate input
         $rules = array('name' => 'required|max:50', 'description' => 'required', 'didyouknow' => 'required', 'reference' => 'required');
         $validation = Validator::make(Input::all(), $rules);
         if ($validation->fails()) {
             Input::flash();
             return Redirect::back()->withInput()->withErrors($validation);
         }
         $task = new Task();
         $task->name = Input::get('name');
         $task->description = Input::get('description');
         $task->didyouknow = Input::get('didyouknow');
         $task->reference = Input::get('reference');
         $task->author = Input::get('taskauthor');
         $task->createdby = 0;
         $task->suspended = 0;
         $task->number = 0;
         $task->save();
         return Redirect::to('tasks/manage');
     }
     return View::make('task.add');
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:25,代码来源:TaskController.php

示例10: create

 /**
  * Show the form for creating a new resource.
  * GET /tasks/create
  *
  * @return Response
  */
 public function create()
 {
     // Rules
     $rules = array('weight' => 'integer|between:1,5', 'name' => 'required');
     // Custom messages
     $messages = array('between' => 'The :attribute must be between :min - :max.', 'integer' => ':attribute must be a number');
     // Create validation
     $validator = Validator::make(Input::all(), $rules, $messages);
     // Check validation
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // Insert the task to database
     $task = new Task();
     $task->project_id = Input::get('projectId');
     $task->user_id = Auth::id();
     $task->name = Input::get('name');
     $task->weight = Input::get('weight');
     if (!Input::get('weight')) {
         $task->weight = 1;
     }
     $task->state = "incomplete";
     $task->save();
     // Increase the users overall task count
     $user = User::find(Auth::id());
     $user->tasks_created = $user->tasks_created + 1;
     $user->save();
     return Redirect::back()->with('success', Input::get('name') . " has been created.");
 }
开发者ID:pradeep1899,项目名称:ALM_Task_Manager,代码行数:35,代码来源:TasksController.php

示例11: store

 public function store()
 {
     $task = new Task(Input::all());
     if (!$task->save()) {
         return Redirect::back()->withInput()->withErrors($task->getErrors());
     }
     return Redirect::home();
 }
开发者ID:Asif-Javed-NUST,项目名称:Lab07,代码行数:8,代码来源:TasksController.php

示例12: store

 /**
  * [addPostTask description]
  */
 public function store()
 {
     if (Input::has('task_label')) {
         $task = new Task();
         $task->label = Input::get('task_label');
         $task->save();
     }
     return Redirect::back();
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:12,代码来源:AdminTasksController.php

示例13: GetNewSEOState

 /**
  * 開始寫入資料
  */
 private function GetNewSEOState()
 {
     $taskModel = new Task();
     $date = new DateTime();
     $taskModel->attributes = array('date' => $date->format("Y-m-d H:i:s"));
     $taskModel->save();
     $taskID = $taskModel->getPrimaryKey();
     $this->GetSEOState($taskID);
 }
开发者ID:wishnoblog,项目名称:SitePageRank,代码行数:12,代码来源:RunController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  * POST /tasks
  *
  * @param Project $project
  * @return Response
  */
 public function store(Project $project)
 {
     $input = Input::all();
     $input['project_id'] = $project->id;
     $task = new Task($input);
     if ($task->save()) {
         return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
     } else {
         return Redirect::route('projects.tasks.create', $project->slug)->withInput()->withErrors($task->errors());
     }
 }
开发者ID:marciocamello,项目名称:laravel-ecommerce,代码行数:18,代码来源:TasksController.php

示例15: run

 public function run()
 {
     $task1 = new Task();
     $task1->description = 'Do something';
     $task1->list_id = 1;
     $task1->save();
     $task2 = new Task();
     $task2->description = 'Do something else';
     $task2->list_id = 1;
     $task2->save();
 }
开发者ID:esmaieldanish,项目名称:laracon-todo-api,代码行数:11,代码来源:TaskSeeder.php


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