public function update($id, $data) { // Checking if subject exists $subject = Subject::find($id); // If subject exists if (!empty($subject)) { // Validating data $validator = Validator::make($data, Subject::updaterules($id)); // If there are no errors in data if (!$validator->fails()) { // Update subject $subject->update($data); // Passing data to response service return $this->responseService->returnMessage($subject, 'Subject was not Updated.'); } else { // Data has errors // Passing errors to response service return $this->responseService->errorMessage($validator->errors()->all()); } } else { // Subject not found // Returning error message return $this->responseService->errorMessage('Subject was not Found.'); } }