Can't really comment much on php code, but I suppose minRole is a string first and then an integer? Probably use a different variable then, just to make that clear.