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