public function getTotalAmount($projectId)
 {
     $project = Project::findOrFail($projectId);
     $dailyLaborSets = $project->dailyLabors->groupBy('pivot.daily_labor_id');
     $totalAmountSet = $dailyLaborSets->map(function ($dailyLabors) {
         return $dailyLabors->sum('pivot.amount');
     });
     return response()->json(['total_amount' => $totalAmountSet]);
 }
 public function store($projectId, Request $request)
 {
     $project = Project::findOrFail($projectId);
     $dailyRecord = $project->dailyRecords()->whereDate((new DailyRecord())->getTable() . '.created_at', '=', new Carbon('today'))->first();
     if ($dailyRecord) {
         $dailyRecord->update(['inspection_record' => $request->input('inspection_record'), 'important_record' => $request->input('important_record')]);
     } else {
         $project->dailyRecords()->create(['inspection_record' => $request->input('inspection_record'), 'important_record' => $request->input('important_record')]);
     }
     return response()->json();
 }
 public function getBouncesByProject($projectId, Request $request)
 {
     $project = Project::findOrFail($projectId);
     $query = $project->costEstimations();
     if ($request->has('cost_estimation_id')) {
         $costEstimation = $project->costEstimations()->findOrFail($request->input('cost_estimation_id'));
         $query->whereDate('settled_at', '<=', $costEstimation->settled_at);
     }
     $costEstimations = $query->with('bounces')->get();
     $results = $costEstimations->map(function ($costEstimation) {
         return $costEstimation->bounces;
     })->collapse()->map($this->getJsonTransformer());
     return response()->json(['cost_estimation_bounces' => $results]);
 }
 public function show($projectId, $checklistId)
 {
     $project = Project::findOrFail($projectId);
     $checklist = ProjectChecklist::findOrFail($checklistId);
     return view('project-checklists.show')->withProject($project)->withChecklist($checklist);
 }