protected function getFinalizationPercent($id) { $counter = 0; $protocol = AcceptanceProtocol::where('Project_FK', '=', $id)->first(); if (count($protocol) > 0) { $counter++; } $manual = ProjectManual::where('Project_FK', '=', $id)->first(); if (count($manual) > 0) { $counter++; } return $counter; }
protected function insertProtocol(Request $request, $id) { $array = Input::all(); $validator = Validator::make($array, ['criteriaName' => 'required', 'criteria' => 'required', 'requirement' => 'required']); if ($validator->fails()) { return Response::json('invalid data', 400); } else { $Protocol = new AcceptanceProtocol(); $Protocol->Project_FK = $id; $Protocol->criteriaName = $request->input('criteriaName'); $Protocol->criteria = $request->input('criteria'); if ($request->input('fulfilled') != null) { $Protocol->fulfilled = true; } else { $Protocol->fulfilled = false; } $Protocol->note = $request->input('note'); $Protocol->requirement = $request->input('requirement'); $Protocol->save(); return Response::json($Protocol); } }