本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}