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


PHP Job::with方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $jobs = Job::with('creator')->orderBy('required_date')->paginate(4);
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(50);
     }
     $data = array('jobs' => $jobs);
     return View::make('temp_jobs.index')->with($data);
 }
开发者ID:fpigeon,项目名称:community-helpers,代码行数:15,代码来源:JobsController.php

示例2: search

 public function search()
 {
     if (Auth::check()) {
         //do not show jobs that have already been applied to
         //to show active jobs that helper has been selected for
         $activeJobIds = DB::table('jobs')->join('helpers_jobs_mapping', function ($join) {
             $join->on('jobs.id', '=', 'helpers_jobs_mapping.job_id')->where('helpers_jobs_mapping.is_accepted', '=', 1);
         })->lists('id');
         $activeJobs = [];
         if (!empty($activeJobIds)) {
             $activeJobs = Job::whereIn('id', $activeJobIds)->get();
         }
         $appliedQuery = Auth::user()->appliedJobs();
         if (!empty($activeJobIds)) {
             $appliedQuery->whereNotIn('id', $activeJobIds);
         }
         $appliedJobs = $appliedQuery->get();
         //$jobsIds will hold all the ids in the jobs table
         $appliedJobIds = array();
         //search all jobs for current job id
         foreach (Auth::user()->appliedJobs as $job) {
             $appliedJobIds[] = $job->id;
         }
         $jobQuery = Job::with('creator');
         if (count($activeJobIds) > 0) {
             $jobQuery->whereNotIn('id', $activeJobIds);
         }
         if (count($appliedJobIds) > 0) {
             $jobQuery->whereNotIn('id', $appliedJobIds);
         }
         //show all jobs if user has not applied to any
         $jobs = $jobQuery->orderBy('required_date')->paginate(5);
         $data = array('jobs' => $jobs, 'activeJobs' => $activeJobs, 'appliedJobs' => $appliedJobs);
     } else {
         $jobs = Job::with('creator')->orderBy('required_date')->paginate(5);
     }
     if (Input::has('filter')) {
         $filter = Input::get('filter');
         $jobs = Job::where('category', $filter)->paginate(50);
     }
     if (Input::has('search')) {
         $search = Input::get('search');
         $jobs = Job::where('description', 'LIKE', '%' . $search . '%')->paginate(5);
     }
     $data = array('jobs' => $jobs);
     return View::make('pages.search')->with($data);
 }
开发者ID:fpigeon,项目名称:community-helpers,代码行数:47,代码来源:HomeController.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $review = Job::with('review')->find($id);
     return View::make('temp_reviews.create-edit')->with('review', $review);
 }
开发者ID:fpigeon,项目名称:community-helpers,代码行数:11,代码来源:ReviewsController.php

示例4: dashboard_helper

 public function dashboard_helper($id)
 {
     //to show active jobs that helper has been selected for
     $activeJobIds = DB::table('jobs')->join('helpers_jobs_mapping', function ($join) {
         $join->on('jobs.id', '=', 'helpers_jobs_mapping.job_id')->where('helpers_jobs_mapping.is_accepted', '=', 1);
     })->lists('id');
     $activeJobs = [];
     if (!empty($activeJobIds)) {
         $activeJobs = Job::whereIn('id', $activeJobIds)->get();
     }
     $appliedQuery = Auth::user()->appliedJobs();
     if (!empty($activeJobIds)) {
         $appliedQuery->whereNotIn('id', $activeJobIds);
     }
     $appliedJobs = $appliedQuery->get();
     //$jobsIds will hold all the ids in the jobs table
     $appliedJobIds = array();
     //search all jobs for current job id
     foreach (Auth::user()->appliedJobs as $job) {
         $appliedJobIds[] = $job->id;
     }
     //do not show jobs that have already been applied to
     $jobQuery = Job::with('creator');
     if (count($activeJobIds) > 0) {
         $jobQuery->whereNotIn('id', $activeJobIds);
     }
     if (count($appliedJobIds) > 0) {
         $jobQuery->whereNotIn('id', $appliedJobIds);
     }
     //show all jobs if user has not applied to any
     $jobs = $jobQuery->orderBy('created_at', 'desc')->paginate(4);
     $data = array('jobs' => $jobs, 'activeJobs' => $activeJobs, 'appliedJobs' => $appliedJobs);
     return View::make('users.show_account')->with($data);
 }
开发者ID:fpigeon,项目名称:community-helpers,代码行数:34,代码来源:UsersController.php


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