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