You need to have a wildcard redirect for subdomains setup on both your development environment and your production environment.
Without them, requests to "http://somerandomsubdomain.example.com" will never even get routed to you application. Laravel won't even get a chance to deal with it.
EDIT: Sorry, I was leaving work when I left that incomplete answer.
Completely separate from your Laravel app, you will need a way for the subdomains to be mapped to an IP address. You will have to set this up on both your development machine(s) and your production server(s).
In production, it's pretty easy. You have to add a DNS entry to create an CNAME record. so that *.example.com
just points to example.com
. Your web host or DNS provider may have to do this for you, if you don't have control or access to your DNS server.
On your development machines, it can be a little tougher. If you are using a local DNS server, or have dnsmasq installed or available (maybe on your router) you will create a CNAME record just like you would in production.
However, many development environments rely on customized hosts files, and you can't to wildcard redirects there. However, if you know what your subdomains will be ahead of time, you can just add the following to /etc/hosts
(OSX or *nix like systems) or %SystemRoot%\system32\drivers\etc\hosts
in Windows:
127.0.0.1 example.dev
127.0.0.1 sub1.example.dev
127.0.0.1 sub2.example.dev
If you give a little more info about your development and production environments, I might be able to help more.
In the meantime, this answer might help a bit too: https://stackoverflow.com/a/79811/388682