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


PHP Project::with方法代码示例

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


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

示例1: saveTrackerEntry

 public function saveTrackerEntry(Request $request)
 {
     // return $request->all();
     $validator = Validator::make($request->all(), ['desc' => 'required|min:5', 'time' => 'required|numeric', 'tags' => 'required', 'project_id' => 'required']);
     if ($request->input('project_id') == 'Select Project') {
         Session::flash('flash_error', 'You need to select the project');
         return redirect()->back()->withInput();
     }
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     try {
         DB::beginTransaction();
         $project = Project::with('client')->find($request->input('project_id'));
         $entry = TimeEntry::create(['desc' => $request->input('desc'), 'user_id' => Auth::user()->id, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $request->input('time')]);
         // adding the entry of the ticket with tags mapping table
         foreach ($request->input('tags') as $key => $value) {
             DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entry->id, 'taggable_type' => 'ticket', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
         }
         if ($request->input('estimate_id')) {
             DB::table('time_entry_estimates')->insert(['time_entry_id' => $entry->id, 'estimate_id' => $request->input('estimate_id'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
             DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $request->input('time'), 'id' => $request->input('estimate_id')]);
         }
         DB::commit();
         Session::flash('flash_message', 'Entry saved');
         return redirect('time-tracker');
     } catch (\PDOException $e) {
         DB::rollBack();
         abort(403, 'Data was not saved. Try again' . $e->getMessage());
     }
 }
开发者ID:amitavroy,项目名称:Tranvas,代码行数:31,代码来源:TrackerController.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Project::with(['positions' => function ($query) {
         $query->with(['targets' => function ($query) {
             $query->withTrashed()->orderBy('created_at', 'desc');
         }]);
     }])->where('id', $id)->first();
 }
开发者ID:mcoyevans,项目名称:personiv-productivity-quality-report,代码行数:14,代码来源:ProjectController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $name = Input::get('name');
     $query = Project::with('photos', 'users');
     if ($name != null) {
         $query->where('name', 'LIKE', "%{$name}%");
     }
     $projects = $query->paginate(10);
     return Response::json($projects->all());
 }
开发者ID:TeamWatermelonIT,项目名称:ItGotTalent,代码行数:15,代码来源:ProjectsController.php

示例4: findOrThrowException

 /**
  * @param $id
  * @param bool $withOrganizations
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withRelations = [])
 {
     if (!empty($withRelations)) {
         $relations = implode(',', $withRelations);
         $project = Project::with($relations)->find($id);
     } else {
         $project = Project::find($id);
     }
     if (!is_null($project)) {
         return $project;
     }
     throw new GeneralException('That project does not exist.');
 }
开发者ID:herzcthu,项目名称:Laravel-HS,代码行数:19,代码来源:EloquentProjectRepository.php

示例5: findOrThrowException

 /**
  * @param $id
  * @param bool $withOrganizations
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withOrganization = false, $withQuestions = false)
 {
     if ($withOrganization && $withQuestions) {
         $project = Project::with('organization', 'questions')->find($id);
     } elseif ($withQuestions) {
         $project = Project::with('questions')->find($id);
     } elseif ($withOrganization) {
         $project = Project::with('organization')->find($id);
     } else {
         $project = Project::find($id);
     }
     if (!is_null($project)) {
         return $project;
     }
     throw new GeneralException('That project does not exist.');
 }
开发者ID:herzcthu,项目名称:Laravel-HS,代码行数:22,代码来源:EloquentProjectRepository.php

示例6: index

 /**
  * @param string $locale
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index($locale = "nl")
 {
     $projects = Project::with(["descriptions", "tasks"]);
     $projects = $projects->get();
     foreach ($projects as $project) {
         $progress = 0;
         if (!$project->is_done) {
             foreach ($project->tasks as $task) {
                 $progress += $task->progress;
             }
             $precentage = 0;
             if (count($project->tasks) != 0) {
                 $precentage = $progress / count($project->tasks);
             }
             $project->progress = round($precentage, 1);
         }
     }
     return view("portfolio.index", ["projects" => $projects]);
 }
开发者ID:aranna00,项目名称:arankieskamp.me,代码行数:24,代码来源:PortfolioController.php

示例7: backdateTimeEntry

 public function backdateTimeEntry($otp, $userId)
 {
     $projects = Project::with('client')->get();
     $tags = Tag::all();
     $otp = DB::table('backdate_timeentry')->where('otp', $otp)->where('user_id', $userId)->where('status', 1)->first();
     if (!$otp) {
         abort(403, 'Wrong url');
     }
     return view('manager.backdate-form', compact('projects', 'tags', 'otp'));
 }
开发者ID:shirishmore,项目名称:timesheet,代码行数:10,代码来源:TrackerController.php

示例8: show

 /**
  * Display the specified resource.
  * @param  int $id
  * @param RevenueVsCost $revenue_vs_cost
  * @return Response
  */
 public function show($id, RevenueVsCost $revenue_vs_cost)
 {
     $project = Project::with(['revenues', 'costs', 'costs.staff'])->findOrFail($id);
     $performance = $revenue_vs_cost->get(['project_id' => $id], ['month_logged']);
     return view('project.show', compact('project', 'performance'));
 }
开发者ID:arsenaltech,项目名称:folio,代码行数:12,代码来源:ProjectController.php

示例9: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Project::with('categories', 'project_images', 'agents', 'project_parts')->findOrFail($id)->toArray();
 }
开发者ID:vankhoektcn,项目名称:Qqsipe2UY67gLO7BWrou,代码行数:10,代码来源:ProjectsController.php

示例10: getProjectsManagement

 public function getProjectsManagement()
 {
     $projects = Project::with('images')->get();
     return view('admin_projects', ['projects' => $projects]);
 }
开发者ID:RKokholm,项目名称:seniva,代码行数:5,代码来源:AdminController.php

示例11: saveTimesheet

 /**
  * Helper function to Save timeEntry
  *
  * @return mixed
  */
 public function saveTimesheet($postdata)
 {
     try {
         $output = array();
         //            \Log::info(print_r($postdata, true));
         DB::beginTransaction();
         $project = Project::with('client')->find($postdata['project_id']);
         // if the user id is set, it means it's a backdate entry
         $createdAt = Carbon::now();
         $updatedAt = Carbon::now();
         $userId = 0;
         if ($postdata['uid']) {
             $userId = $postdata['uid'];
             $timestamp = $postdata['start_time'] / 1000;
             $createdAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
             $updatedAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
         }
         $entryId = DB::table('time_entries')->insertGetId(['desc' => $postdata['desc'], 'user_id' => $userId, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $postdata['total_time'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
         $tagsArr = explode(',', $postdata['tags']);
         // adding the entry of the ticket with tags mapping table
         foreach ($tagsArr as $key => $value) {
             DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entryId, 'taggable_type' => 'ticket', 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
         }
         $output = array('id' => $entryId, 'uid' => $userId, 'desc' => $postdata['desc'], 'project_id' => $postdata['project_id'], 'project' => $project->name, 'total_time' => $postdata['total_time'], 'start_time' => $postdata['start_time'], 'end_time' => $postdata['end_time'], 'tags' => $postdata['tags'], 'client_name' => $project->client->name);
         if (isset($postdata['estimate_id']) && $postdata['estimate_id'] != 0) {
             DB::table('time_entry_estimates')->insert(['time_entry_id' => $entryId, 'estimate_id' => $postdata['estimate_id'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
             DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $postdata['total_time'], 'id' => $postdata['estimate_id']]);
         }
         $output['estimate_id'] = $postdata['estimate_id'];
         DB::commit();
         return response($output, 201);
     } catch (\PDOException $e) {
         DB::rollBack();
         abort(403, 'Data was not saved. Try again' . $e->getMessage());
     }
 }
开发者ID:snehachavan21,项目名称:timesheet,代码行数:41,代码来源:RestController.php

示例12: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $projects = Project::with('client')->get();
     return view('projects.index', compact('projects'));
 }
开发者ID:kodefly,项目名称:kode-agile,代码行数:10,代码来源:ProjectsController.php

示例13: monthly

 public function monthly()
 {
     $this->date_start = new Carbon('first Monday of this month');
     $this->date_end = new Carbon('last Monday of this month');
     $projects = Project::with('positions')->get();
     foreach ($projects as $project_key => $project) {
         $project->first_report = Report::where('project_id', $project->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->first();
         if ($project->first_report) {
             $project->date_start = $this->date_start->toFormattedDateString();
             $project->date_end = $this->date_end->toFormattedDateString();
             $project->members = Experience::with(['member' => function ($query) {
                 $query->withTrashed();
             }])->where('project_id', $project->id)->get();
             $project->beginner_total_output = 0;
             $project->beginner_total_hours_worked = 0;
             $project->beginner_total_average_output = 0;
             $project->moderately_experienced_total_output = 0;
             $project->moderately_experienced_total_hours_worked = 0;
             $project->moderately_experienced_total_average_output = 0;
             $project->experienced_total_output = 0;
             $project->experienced_total_hours_worked = 0;
             $project->experienced_total_average_output = 0;
             foreach ($project->positions as $position_key => $position) {
                 $position->beginner = 0;
                 $position->moderately_experienced = 0;
                 $position->experienced = 0;
                 $position->beginner_total_output = 0;
                 $position->beginner_total_hours_worked = 0;
                 $position->beginner_total_average_output = 0;
                 $position->moderately_experienced_total_output = 0;
                 $position->moderately_experienced_total_hours_worked = 0;
                 $position->moderately_experienced_total_average_output = 0;
                 $position->experienced_total_output = 0;
                 $position->experienced_total_hours_worked = 0;
                 $position->experienced_total_average_output = 0;
             }
             foreach ($project->members as $member_key => $member) {
                 $member->positions = $project->positions;
                 $member->roles = 0;
                 $overall_monthly_productivity = 0;
                 $overall_monthly_quality = 0;
                 $overall_count = 0;
                 foreach ($member->positions as $position_key => $position) {
                     $performances = Performance::with('project', 'position')->with(['target' => function ($query) {
                         $query->withTrashed();
                     }])->with(['member' => function ($query) {
                         $query->withTrashed()->with(['experiences' => function ($query) {
                             $query->with('project');
                         }]);
                     }])->where('daily_work_hours', 'like', $project->first_report->daily_work_hours . '%')->where('position_id', $position->id)->where('member_id', $member->member_id)->whereBetween('date_start', [$this->date_start, $this->date_end])->get();
                     if (count($performances)) {
                         $member->roles++;
                         $position->total_hours_worked = 0;
                         $position->total_output = 0;
                         $position->total_output_error = 0;
                         $position->total_average_output = 0;
                         $position->monthly_productivity = 0;
                         $position->monthly_quality = 0;
                         foreach ($performances as $performance_key => $performance) {
                             $position->total_hours_worked += $performance->hours_worked;
                             $position->total_output += $performance->output;
                             $position->total_output_error += $performance->output_error;
                             if ($performance->target->experience == 'Beginner') {
                                 if ($performance_key === 0) {
                                     $project->positions[$position_key]->beginner += 1;
                                 }
                                 $project->positions[$position_key]->beginner_total_output += $performance->output;
                                 $project->positions[$position_key]->beginner_total_hours_worked += $performance->hours_worked;
                             } else {
                                 if ($performance->target->experience == 'Moderately Experienced') {
                                     if ($performance_key === 0) {
                                         $project->positions[$position_key]->moderately_experienced += 1;
                                     }
                                     $project->positions[$position_key]->moderately_experienced_total_output += $performance->output;
                                     $project->positions[$position_key]->moderately_experienced_total_hours_worked += $performance->hours_worked;
                                 } else {
                                     if ($performance->target->experience == 'Experienced') {
                                         if ($performance_key === 0) {
                                             $project->positions[$position_key]->experienced += 1;
                                         }
                                         $project->positions[$position_key]->experienced_total_output += $performance->output;
                                         $project->positions[$position_key]->experienced_total_hours_worked += $performance->hours_worked;
                                     }
                                 }
                             }
                         }
                         $project->positions[$position_key]->head_count = $project->positions[$position_key]->beginner + $project->positions[$position_key]->moderately_experienced + $project->positions[$position_key]->experienced;
                         $position->total_average_output = round($position->total_output / $position->total_hours_worked * $performances[0]->daily_work_hours, 2);
                         $position->monthly_productivity = round($position->total_average_output / $performances[0]->target->productivity * 100, 2);
                         $position->monthly_quality = round((1 - $position->total_output_error / $position->total_output) * 100, 2);
                         if ($position->monthly_productivity < 100 && $position->monthly_quality >= $performances[0]->target->quality) {
                             $position->quadrant = 'Quadrant 1';
                         } else {
                             if ($position->monthly_productivity >= 100 && $position->monthly_quality >= $performances[0]->target->quality) {
                                 $position->quadrant = 'Quadrant 2';
                             } else {
                                 if ($position->monthly_productivity >= 100 && $position->monthly_quality < $performances[0]->target->quality) {
                                     $position->quadrant = 'Quadrant 3';
                                 } else {
                                     if ($position->monthly_productivity < 100 && $position->monthly_quality < $performances[0]->target->quality) {
//.........这里部分代码省略.........
开发者ID:mcoyevans,项目名称:personiv-productivity-quality-report,代码行数:101,代码来源:ReportController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $projects = Project::with('company', 'step')->get();
     return view('project.index', compact('projects'));
 }
开发者ID:sunhuang2015,项目名称:proj,代码行数:11,代码来源:ProjectController.php

示例15: invoice

 /**
  * Invoice
  */
 public function invoice($id)
 {
     $project = Project::with(['tasks' => function ($query) {
         $query->whereNotNull('closed_at')->orderBy('closed_at');
     }])->find($id);
     return PDF::loadView('project.invoice', compact('project'))->stream();
     //->download(Str::slug($project->name) . '.pdf');
 }
开发者ID:Rhenan,项目名称:tasks,代码行数:11,代码来源:ProjectController.php


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