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


PHP app\Task類代碼示例

本文整理匯總了PHP中app\Task的典型用法代碼示例。如果您正苦於以下問題:PHP Task類的具體用法?PHP Task怎麽用?PHP Task使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: store

 public function store(Request $request, Task $task)
 {
     $task->addNote(new Note($request->all()));
     $task->setUpdatedAt(Carbon::now()->toDateTimeString());
     $task->save();
     return back();
 }
開發者ID:macewanCS,項目名稱:librasoft,代碼行數:7,代碼來源:NotesController.php

示例2: destroy

 /**
  * Destroy the given task.
  *
  * @param  Request  $request
  * @param  Task  $task
  * @return Response
  */
 public function destroy(Request $request, Task $task)
 {
     if (\Auth::id() == $task->user_id) {
         $task->delete();
     }
     return redirect('/tasks');
 }
開發者ID:anhtt93,項目名稱:BookStore,代碼行數:14,代碼來源:TaskController.php

示例3: pathProgress

 /**
  * checks each step of the path if it was completed (based on its timestamp).
  * also calls the findCrossingPath method to (surprise!) find the paths crossing the current path
  *
  * @param Task $task
  */
 public static function pathProgress(Task $task)
 {
     if ($task->path->isEmpty()) {
         $task->army->update(['task_id' => 0, 'path_id' => 0]);
         $task->delete();
         return;
     }
     $path = $task->path;
     self::processFoodConsumption($path);
     $finished = null;
     $path->filter(function ($item) use(&$finished) {
         if ($item->finished_at <= Carbon::now()) {
             // if the step is finished
             self::findCrossingPath($item);
             $finished = $item;
             $item->delete();
         }
     });
     // now $finished is the last element of the path.
     // $finished has the hex where the army is
     if ($finished != null) {
         $army = $task->army;
         $army->currentHex->update(['army_id' => 0]);
         $army->update(['current_hex_id' => $finished->hex_id]);
         $finished->hex->update(['army_id' => $army->id]);
     }
     if ($path->isEmpty()) {
         $task->army->update(['task_id' => 0, 'path_id' => 0]);
         $task->delete();
     }
 }
開發者ID:nadapapa,項目名稱:PHP-RTS-game,代碼行數:37,代碼來源:ArmyController.php

示例4: create

 /**
  * Create a new task` for the given user and data.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @param  array  $data
  * @return \App\Task
  */
 public function create($user, array $data)
 {
     $task = new Task($data);
     $task->user_id = $user->id;
     $task->save();
     return $task;
 }
開發者ID:luismec90,項目名稱:laravel-todo-app-best-practices,代碼行數:14,代碼來源:EloquentTaskRepository.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $task = new Task();
     $task->name = $request->name;
     $task->user_id = $request->user_id;
     $task->save();
 }
開發者ID:JCombee,項目名稱:dolphin,代碼行數:13,代碼來源:TaskController.php

示例6: getDelete

 public function getDelete(Task $task)
 {
     if ($task->user_id == Auth::user()->id) {
         //delete task als de juiste user is ingelogd
         $task->delete();
     }
     return Redirect::route('home');
 }
開發者ID:gurbuzhasan,項目名稱:web-backend-oplossingen,代碼行數:8,代碼來源:PagesController.php

示例7: newtask

 public function newtask(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:10']);
     $task = new Task();
     $task->name = $request->name;
     $task->save();
     return redirect('tasks');
 }
開發者ID:bg1ufp,項目名稱:laravel-study,代碼行數:8,代碼來源:TaskController.php

示例8: createTask

 public static function createTask($input)
 {
     $task = new Task();
     $task->title = $input['title'];
     $task->complete = $input['complete'];
     $task->save();
     return $task;
 }
開發者ID:rilonx,項目名稱:todo-api,代碼行數:8,代碼來源:Task.php

示例9: save

 public function save(Task $task, $members = null)
 {
     $task->save();
     /* Insert Task Members to Pivot Table */
     if ($members) {
         $task->syncMembers($members);
     }
     return true;
 }
開發者ID:ehomeuc,項目名稱:ehome,代碼行數:9,代碼來源:TaskRepository.php

示例10: testSetLabelToTask

 function testSetLabelToTask()
 {
     $label = factory(\App\ProjectLabel::class)->make(['name' => "foo"]);
     $this->project->labels()->save($label);
     $this->task->label()->associate($label)->save();
     $this->assertEquals('foo', $this->task->label->name);
     $this->assertEquals(2, $this->task->activity->count());
     $this->assertEquals($label->id, $this->task->activity->get(1)->note);
 }
開發者ID:absolux,項目名稱:Collabor8-php-api,代碼行數:9,代碼來源:TaskTest.php

示例11: seedTasks

 public function seedTasks($faker)
 {
     foreach (range(0, 100) as $number) {
         $task = new Task();
         $task->name = $faker->sentence;
         $task->done = $faker->boolean;
         $task->priority = $faker->randomDigit;
         $task->save();
     }
 }
開發者ID:albertmayor,項目名稱:tasksAPI,代碼行數:10,代碼來源:DatabaseSeeder.php

示例12: seedTasks

 /**
  * @param Faker $faker
  */
 private function seedTasks($faker)
 {
     foreach (range(0, 100) as $item) {
         $task = new Task();
         $task->name = $faker->sentence();
         $task->done = $faker->boolean();
         $task->priority = $faker->randomDigit();
         $task->save();
     }
 }
開發者ID:Germangalia,項目名稱:tasksAPI,代碼行數:13,代碼來源:DatabaseSeeder.php

示例13: add

 /**
  * Function for adding new user to database
  * @param Request $request [http request with data]
  * @return id [id of the task added]
  */
 public function add(Request $request)
 {
     if (Auth::check()) {
         $user_id = Auth::user()->id;
         $task = new Task();
         $task->task_name = $request->task_name;
         $task->user_id = $user_id;
         $task->save();
         return $task->id;
     }
 }
開發者ID:shile23,項目名稱:laravel-todo,代碼行數:16,代碼來源:TasksController.php

示例14: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     $input = $request->all();
     $mTask = new Task();
     $task = $mTask->getTaskById($id);
     //        dd($task->toArray());
     $task->saveTask($id, $input);
     //        Session::flash('flash_message', 'Task successfully added!');
     return redirect()->back()->with('flash_message', 'Task successfully added!');
 }
開發者ID:vudn-job,項目名稱:todo-list,代碼行數:17,代碼來源:TasksController.php

示例15: finishTask

 /**
  * @param Task $task
  */
 public static function finishTask(Task $task)
 {
     switch ($task->type) {
         case 1:
             // create worker
             $task->building->city->human_resources->workers += 1;
             $task->building->city->human_resources->save();
             $task->delete();
             break;
         case 2:
             // create settler
             $task->building->city->human_resources->settlers += 1;
             $task->building->city->human_resources->save();
             $task->delete();
             break;
         case 3:
             // create a general
             if ($task->building->city->hex->army_id == 0) {
                 $army = Army::create(['user_id' => $task->building->city->owner, 'current_hex_id' => $task->building->city->hex->id]);
                 $task->building->city->hex->army_id = $army->id;
                 $task->building->city->hex->save();
             }
             if ($task->building->city->hex->army->general) {
                 break;
             }
             $task->building->city->hex->army->update(['general' => true]);
             $task->delete();
             break;
         case 11:
             // create unit
         // create unit
         case 12:
         case 13:
         case 14:
         case 15:
         case 16:
         case 17:
             if ($task->building->city->hex->army_id == 0) {
                 $army = Army::create(['user_id' => $task->building->city->owner, 'current_hex_id' => $task->building->city->hex->id]);
                 $task->building->city->hex->army_id = $army->id;
                 $task->building->city->hex->save();
             }
             $unit_type = 'unit' . ($task->type - 10);
             $task->building->city->hex->army->{$unit_type} += 1;
             $task->building->city->hex->army->save();
             $task->delete();
             break;
         case 20:
             // move army
             ArmyController::pathProgress($task);
             break;
     }
 }
開發者ID:nadapapa,項目名稱:PHP-RTS-game,代碼行數:56,代碼來源:TaskController.php


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