In this episode, we take a closer look at how we handle subdomains in our application, especially when it comes to validation. At first, our validation rules make it impossible to remove a subdomain—if you try to clear it out, it complains that the subdomain must be a string of letters. Not ideal if a user wants to have no subdomain at all!
To fix this, we jump into the profile update request and make the subdomain field nullable. This change tells Laravel to ignore the other validation rules when the field is left empty (i.e., null). After making this update, we can now remove the subdomain entirely, save the profile, and the system behaves just as expected—if you try to access the old subdomain URL, you’ll get a 404.
Finally, we quickly demonstrate bringing back the subdomain and saving it again, showing that everything works smoothly in both cases. This update makes the user experience a lot more flexible when managing subdomains!