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


PHP Task::create方法代碼示例

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


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

示例1: postTask

 function postTask(Request $request)
 {
     $task = $request->all();
     Task::create($task);
     $comm = Committee::where('id', $task['comm_id'])->first();
     $evnt = Event::where('id', $comm['event_id'])->first();
     //UPDATING WEIGHT OF COMMITTEE AND EVENT
     $comm->increment('weight', $task['weight']);
     $evnt->increment('weight', $task['weight']);
     //UPDATING PROGRESS OF COMMITTEE
     $progress = 0;
     $tasks = Task::where('comm_id', $comm->id)->get();
     foreach ($tasks as $task1) {
         $progress += $task1->weight * $task1->progress;
     }
     $progress = $progress / $comm->weight;
     $comm->progress = $progress;
     $comm->save();
     //UPDATING PROGRESS OF EVENT
     $progress2 = 0;
     $committees = Committee::all();
     foreach ($committees as $committee) {
         if ($committee->event_id == $evnt->id) {
             $progress2 += $committee->weight * $committee->progress;
         }
     }
     $progress2 = $progress2 / $evnt->weight;
     $evnt->progress = $progress2;
     $evnt->save();
     return redirect('profile');
 }
開發者ID:zoekayvee,項目名稱:YSESTracker,代碼行數:31,代碼來源:TaskController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 10; $i++) {
         $j = rand(0, 1000);
         Task::create(['author' => 'Testowy Autor ' . $j, 'name' => 'Testowe Zadanie ' . $j, 'category_id' => 1, 'user_id' => 1]);
     }
 }
開發者ID:mikolajszczepanski,項目名稱:NuPtr,代碼行數:12,代碼來源:TasksTableSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Task::create(['user_id' => '1', 'title' => $faker->sentence(4), 'content' => $faker->paragraphs(8, true), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now(), 'due_at' => $faker->dateTimeBetween('+1 days', '+2 years')->format('m/d/Y')]);
     }
 }
開發者ID:vowsdesrat,項目名稱:laravel,代碼行數:12,代碼來源:TasksTableSeeder.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $arrRet = array('success' => false);
     if (empty($request->get('title'))) {
         $arrRet['errors'][] = "The title cannot be empty.";
     }
     if (empty($request->get('description'))) {
         $arrRet['errors'][] = "The description cannot be empty.";
     }
     if (empty($request->get('categoryId'))) {
         $arrRet['errors'][] = "Please select a category.";
     }
     if (empty($request->get('userId'))) {
         $arrRet['errors'][] = "Please assign the task to a user.";
     }
     if (empty($arrRet['errors'])) {
         // We are good no errors
         $task = new Task();
         $created = $task->create(['title' => $request->get('title'), 'description' => $request->get('description'), 'category_id' => $request->get('categoryId'), 'user_id' => $request->get('userId')]);
         if ($created) {
             $arrRet['success'] = true;
             $arrRet['task'] = $created;
         }
     }
     return response()->json($arrRet);
 }
開發者ID:tanko2224,項目名稱:envoy-todo-list,代碼行數:33,代碼來源:TaskController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Project $project)
 {
     $input = Input::all();
     $input['project_id'] = $project->id;
     Task::create($input);
     return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
 }
開發者ID:shima-rahman,項目名稱:lina,代碼行數:12,代碼來源:TasksController.php

示例6: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         Task::create(['user_id' => rand(1, 4), 'title' => implode($faker->sentences(2)), 'priority_id' => rand(1, 4), 'notes' => implode($faker->paragraphs(4))]);
     }
 }
開發者ID:kmassada,項目名稱:laravel-angular,代碼行數:12,代碼來源:TasksTableSeeder.php

示例7: store

 public function store(CreateTaskRequest $request)
 {
     $data = ['work' => Input::get('workName'), 'status' => 'Incomplete'];
     $response = Task::create($data);
     if ($response) {
         return redirect()->back();
     }
 }
開發者ID:nayem73cse12,項目名稱:Laravel_first_CRUD,代碼行數:8,代碼來源:TodoController.php

示例8: store

 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     $input = $request->all();
     Task::create($input);
     \Session::flash('flash_message', 'Tarea agregada');
     return redirect()->back();
 }
開發者ID:JuanVqz,項目名稱:crud5,代碼行數:8,代碼來源:TasksController.php

示例9: store

 public function store(CreateTask $request)
 {
     //dd($request->all());
     Task::create($request->all());
     return redirect('todolist');
     // var_dump($request::all());
     // Task::create($request::all());
 }
開發者ID:piyushpk89,項目名稱:MasteringLaravelCode_by_Christopher_John,代碼行數:8,代碼來源:TasksController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['tar_title' => 'required', 'tar_descripcion' => 'required']);
     $input = $request->all();
     Task::create($input);
     $request->session()->flash('flash_message', 'Se agrego la Tarea!');
     return redirect()->back();
 }
開發者ID:akrz,項目名稱:ejemploTareas,代碼行數:14,代碼來源:TasksController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required', 'description' => 'required']);
     $input = $request->all();
     Task::create($input);
     Session::flash('flash_message', 'Задача успешно добавлена!');
     return redirect()->back();
 }
開發者ID:GanjaGanja,項目名稱:crud,代碼行數:14,代碼來源:TasksController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *  @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('name') or !Input::get('done') or !Input::get('priority')) {
         return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)->respondWithError('Parameters failed validation for a task.');
     }
     Task::create(Input::all());
     return $this->respondCreated('Task successfully created.');
 }
開發者ID:Germangalia,項目名稱:tasksAPI,代碼行數:12,代碼來源:TaskController.php

示例13: postCreateTask

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postCreateTask(Request $request)
 {
     $task['content'] = $request->get('content');
     $task['user_id'] = Auth::user()->id;
     $task['list_id'] = $request->get('list_id');
     $task['complete'] = 0;
     return \App\Task::create($task);
 }
開發者ID:ahuggins,項目名稱:taskr,代碼行數:14,代碼來源:TaskController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($task = Task::create($request->all())) {
         return $task->toJson();
     } else {
         return $this->response->error('Task could not be created.', 404);
     }
 }
開發者ID:sax69sax,項目名稱:task-manager-api,代碼行數:14,代碼來源:TasksController.php

示例15: store

 public function store($todolist_id)
 {
     $name = Input::get('name');
     $completed = Input::get('completed');
     Task::create(array('todolist_id' => $todolist_id, 'name' => $name, 'completed' => $completed));
     $id = DB::table('tasks')->where('name', '=', $name)->pluck('id');
     return Response::json(['name' => $name, 'id' => $id, 'completed' => $completed, 'todolist_id' => $todolist_id]);
 }
開發者ID:brendamrl816,項目名稱:gm-planner,代碼行數:8,代碼來源:TasksController.php


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