本文整理汇总了PHP中app\Project::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::join方法的具体用法?PHP Project::join怎么用?PHP Project::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$projects = Project::join('project_resident', 'project_resident.project_id', '=', 'projects.id')->join('residents', 'residents.id', '=', 'project_resident.resident_id')->where('residents.id', '=', Auth::user()->id)->get(['projects.*']);
$etapas = stage::all();
return view('residente.avance', compact('projects', 'etapas'));
}
示例2: actualizar
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function actualizar(Request $request)
{
$data = $request->all();
$change = Activity_Stage::where('activity_id', '=', $data['activity_id'])->where('stage_project_id', '=', $data['stage_project_id'])->first();
$change->fill($data);
$change->material = $data['material'];
$change->save();
$project = Project::join('project_stage', 'project_stage.project_id', '=', 'projects.id')->join('activity_stage', 'activity_stage.stage_project_id', '=', 'project_stage.id')->where('project_stage.id', '=', $data['stage_project_id'])->get(['projects.*']);
$project = Project::find($project->first()->id);
$all = Activity_Stage::join('project_stage', 'project_stage.id', '=', 'activity_stage.stage_project_id')->join('projects', 'projects.id', '=', 'project_stage.project_id')->where('projects.id', '=', $project->id)->get(['activity_stage.*']);
$valor_total = 0;
foreach ($all as $a) {
$valor = 0;
$valor += $a->hand + $a->transport + $a->material;
$valor_total += $valor * $a->quantity;
}
$project->budget = $valor_total;
$project->save();
return response()->json([$all]);
}