本文整理汇总了PHP中app\Project::leftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::leftJoin方法的具体用法?PHP Project::leftJoin怎么用?PHP Project::leftJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::leftJoin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show(Request $request, $id)
{
//
$data = $request->all();
$id_period = $data['id_period'];
if ($id == 1) {
// Add code for load teacher whitout period
$teachers = \App\Project::leftJoin('registry_projects', function ($join) use($id_period) {
$join->on('projects.id', '=', 'registry_projects.id_project')->where('registry_projects.id_period', '=', $id_period);
})->whereNull('registry_projects.id_project')->Where('projects.active', 1)->select('projects.id', 'projects.name')->get()->toJson();
// dd($teacher);
} else {
// Add code for load teacher whit period
$teachers = \App\RegistryProject::Join('projects', 'projects.id', '=', 'registry_projects.id_project')->select('registry_projects.id as id_registry_project', 'projects.id', 'projects.name')->Where('registry_projects.id_period', $id_period)->get()->toJson();
}
$status = count(json_decode($teachers, true)) > 0 ? true : false;
if ($request->ajax()) {
return response()->json(['status' => $status, 'data' => $teachers]);
}
}
示例2: getTop10ProjectsWithMostFeedbacks
public function getTop10ProjectsWithMostFeedbacks()
{
return Project::leftJoin('project_user', 'projects.id', '=', 'project_user.project_id')->select('projects.name', DB::raw('COUNT(project_user.user_id) as aggregate'))->groupBy('id')->orderBy('aggregate', 'DESC')->limit(10)->get()->toJSON();
}
示例3: projects
/**
* Projects associated with the user
*
* Returns a Builder instance rather than a relation because of
* the manual left join to client_user. A hasManyThrough relation
* would not work because of the many-to-many relationship between
* users and clients.
*
* @return Builder
*/
public function projects()
{
$query = Project::leftJoin('client_user', 'client_user.client_id', '=', 'projects.client_id');
$query->where('client_user.user_id', $this->getKey());
return $query;
}
示例4: opciones
public function opciones()
{
$projects = Project::leftJoin('homes', 'homes.project_id', '=', 'projects.id')->select('projects.*', DB::raw('count(*) as n_casas'))->groupBy('projects.id')->get();
return view('admin.project.option', compact('projects'));
}