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


PHP Task::with方法代码示例

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


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

示例1: demo_efficient_eager_loading_eloquent_relationship_query

 /** @test */
 public function demo_efficient_eager_loading_eloquent_relationship_query(FunctionalTester $I)
 {
     // given ... 3 tasks, each belonging to a user
     // when ... we get tasks "with" their user
     //          it would result in only 2 SQL queries in total (which is efficient)
     $tasks = Task::with('user')->get();
     // then ... should return all tasks with their user
     $I->assertSame(3, count($tasks));
     $I->assertSame("Sherlock Holmes", $tasks[0]->user['name']);
     // task 1
     $I->assertSame("Sherlock Holmes", $tasks[1]->user['name']);
     // task 2
     $I->assertSame("Dr Watson", $tasks[2]->user['name']);
     // task 3
 }
开发者ID:neilrussell6,项目名称:l5-task-list,代码行数:16,代码来源:Task_userCest.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $issues = Issue::with('company', 'company.person')->has('task', '<', 1)->get();
     foreach ($issues as $issue) {
         $task = new Task();
         $task->issue_id = $issue->id;
         $task->person_id = $issue->company->person->id;
         $task->priority = $issue->level * $issue->company->score;
         $task->save();
     }
     $tasks = Task::with('issue', 'issue.company', 'person')->orderBy('priority', 'DESC')->get();
     echo 'ID | Name | Company | Priority | Assigned Person', PHP_EOL;
     foreach ($tasks as $task) {
         echo sprintf('%d | %s | %s | %d | %s', $task->id, $task->issue->name, $task->issue->company->name, $task->priority, $task->person->name), PHP_EOL;
     }
 }
开发者ID:LakyLak,项目名称:Projects,代码行数:21,代码来源:DisplayTasks.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //$tasks = Task::take(100)->get();
     //$tasks = Task::with('assignees')->get();
     // TODO MAKE SURE YOU CAN'T DUPLICATE ASSIGNEES
     $tasks = Task::with(['assignees' => function ($query) {
         // Puts the current user first in the array of assignees
         $query->orderByRaw('id = ? DESC', Auth::user()->id);
     }, 'tags'])->get();
     // DB::table('users')->chunk(100, function($users) {
     //     foreach ($users as $user) {
     //         //
     //     }
     // });
     $users = User::all();
     $tags = Tag::all();
     return view('tasks/tasks')->with(array('tasks' => $tasks, 'users' => $users, 'tags' => $tags));
 }
开发者ID:cclass,项目名称:taskboard,代码行数:23,代码来源:TaskController.php

示例4: get

 /**
  * GET /api/dashboard
  *
  * @param $userId
  * @param $partnerId
  * @param Request $request
  *
  * @return
  */
 public function get($userId, $partnerId, Request $request)
 {
     // Get current room
     $room = $request->room;
     $progressions = Progression::where('room_id', '=', $room->id)->get();
     $tasksIds = [];
     $tasks = [];
     // Get all tasks use in the room
     foreach ($progressions as $value) {
         if (!in_array($value->task_id, $tasksIds)) {
             $tasksIds[] = $value->task_id;
             $task = Task::with('category')->where('id', '=', $value->task_id)->first();
             $userProgression = Progression::where('room_id', '=', $room->id)->where('user_id', '=', $userId)->where('task_id', '=', $task->id)->first(['count']);
             $partnerProgression = Progression::where('room_id', '=', $room->id)->where('user_id', '=', $partnerId)->where('task_id', '=', $task->id)->first(['count']);
             $tasks[] = ['id' => $task->id, 'category' => $task->category, 'name' => $task->name, 'difference' => $userProgression->count - $partnerProgression->count];
         }
     }
     // Return response
     return Response::json(['status_code' => 200, 'tasks' => $tasks]);
 }
开发者ID:Mathew78540,项目名称:both,代码行数:29,代码来源:DashboardController.php

示例5: taskexcel

 public function taskexcel($id)
 {
     Excel::create('Excel ', function ($excel) use($id) {
         $excel->sheet('new Sheet', function ($sheet) use($id) {
             $taskforms = TaskForm::where('task_id', $id)->with('device')->get();
             $task = Task::with('company')->find($id);
             $sheet->setAllBorders('thin');
             $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 10, 'bold' => false)));
             // Set border for cells
             $sheet->loadView('report.taskexcel')->with('taskforms', $taskforms)->with('task', $task);
         });
     })->download('xls');
 }
开发者ID:sunhuang2015,项目名称:mytask,代码行数:13,代码来源:ReportController.php

示例6: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     return Task::with('tasklist')->findOrFail($id)->toJson();
 }
开发者ID:sax69sax,项目名称:task-manager-api,代码行数:10,代码来源:TasksController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     return response()->json(Task::with('user', 'category')->get());
 }
开发者ID:tanko2224,项目名称:envoy-todo-list,代码行数:10,代码来源:TaskController.php

示例8: forUser

 /**
  * @param User $user
  * @return App\Task[]
  */
 public function forUser(User $user)
 {
     //        return $user->tasks()->getResults();
     return Task::with('user')->withTrashed()->where('user_id', $user->id)->orderBy('created_at', 'asc')->get();
 }
开发者ID:grisoni77,项目名称:laravel_tutorial,代码行数:9,代码来源:TaskRepository.php

示例9: history

 /**
  * History page
  */
 public function history()
 {
     //get timezone offset for scoreboard
     $offset = new DateTime('now', new DateTimeZone(Auth::user()->timezone));
     $time = time() + $offset->getOffset();
     //get last six days' totals
     $days = $weeks = [];
     for ($i = 0; $i < 6; $i++) {
         $day = $time - 60 * 60 * 24 * $i;
         $end = $time - 60 * 60 * 24 * 7 * $i;
         $start = $time - 60 * 60 * 24 * 7 * ($i + 1) + 60 * 60 * 24;
         $weeks[date('M j', $start) . '–' . date('M j', $end)] = Task::where('closed_at', '>=', date('Y-m-d', $start))->where('closed_at', '<=', date('Y-m-d', $end))->sum('hours');
         $days[date('l', $day)] = Task::where('closed_at', date('Y-m-d', $day))->sum('hours');
     }
     //$days = array_reverse($days);
     //dd($weeks);
     //get tasks
     $tasks = Task::with('project')->whereNotNull('closed_at')->orderBy('closed_at', 'desc')->orderBy('updated_at', 'desc')->paginate(20);
     return view('task.history', compact('days', 'weeks', 'tasks'));
 }
开发者ID:Rhenan,项目名称:tasks,代码行数:23,代码来源:TaskController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $tasks = Task::with('company', 'step', 'category', 'log')->where('step_id', '<', 7)->get();
     return view('task.list', compact('tasks'));
 }
开发者ID:sunhuang2015,项目名称:mytask,代码行数:11,代码来源:TaskController.php

示例11: index

 public function index()
 {
     //
     $tasks = Task::with(['company', 'step'])->orderBy('created_at', 'DESC')->get();
     return view('task.index', compact('tasks'));
 }
开发者ID:sunhuang2015,项目名称:feotask,代码行数:6,代码来源:TaskController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(Task $task, TaskRequest $request)
 {
     Log::info("[App\\TaskController]: Get a Task");
     $task = Task::with('priority', 'tags')->where('id', $task->id)->first();
     return response()->json($task);
 }
开发者ID:kmassada,项目名称:laravel-angular,代码行数:12,代码来源:TaskController.php

示例13: apitasks

 public function apitasks()
 {
     $tasks = Task::with('owner', 'assigned')->get();
     return $tasks;
 }
开发者ID:andbet39,项目名称:things,代码行数:5,代码来源:TaskController.php

示例14: index

 /**
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * List all available tasks and output in json
  */
 public function index()
 {
     $Tasks = Task::with('task_done')->get();
     return response()->json($Tasks);
 }
开发者ID:nextlevelshit,项目名称:lumen-dailyshit-api,代码行数:10,代码来源:TaskController.php


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