For subdomain path Laravel and maybe Lumen have a routing pattern design specifically for subdomain content.
here is the snippet taken from the laravel 5.6 documentation:
Sub-Domain Routing Route groups may also be used to handle sub-domain routing. Sub-domains may be assigned route parameters just like route URIs, allowing you to capture a portion of the sub-domain for usage in your route or controller. The sub-domain may be specified by calling the domain method before defining the group:
Route::domain('{account}.myapp.com')->group(function () {
Route::get('user/{id}', function ($account, $id) {
//
});
});
If you was to replace {account} with your language en, fr, de etc and myapp.com with your top level domain then you could use the language as set by your subdomain in this snippet {account} in your controller to dictate what data it grabs from your database or api.
Thank you for your reply! So I have created my own package for that. Since I could not find what I wanted elsewhere.
Glad to hear you have created a open source package I have added it to my Githubs watch list. Best of luck with your application
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community