code: public function rules()
      {
          switch($this->method())
          {
              case 'GET':
              case 'DELETE':
              {
                  return [];
              }
              case 'POST':
              {
                  return [
                      'name' => 'required|min:3|max:255|unique:roles,name',
                  ];
              }
              case 'PUT':
              case 'PATCH':
              {
                  $id = $this->route()->roles;
                  $role = Role::findOrFail($id);
                  return [
                      'name' => 'required|min:3|max:255|unique:roles,name,'.$role->id,
                  ];
              }
              default:break;
          }
      }
docs: Get the validation rules that apply to the request.
  
  @return array