Scenario
I have setup Laravel application routes in such a way that, where
Route::group(["domain" => getSubDomain()->sub_domain,"middleware"=>
["guest"]], function () {
//member routes
});
have one helper function getSubDomain()->sub_domain, which is checking sub_domain allowed in companies table. here is the helper function code
$domain = \App\Model\Company::where('sub_domain', request()->getHost())->whereIn("company_type_id", (array)$company_type_id)->first();
return !empty($domain) ? $domain : new \App\Model\Company(
[
"sub_domain" => !in_array(4, $company_type_id) ? env("sub_domain") : "",
"welcome_message" => env("welcome_message"),
"domain_flag" => "assets/images/dev-logo.png"
]);
In short this helper function will check in database about the sub domain is what? and based on valid sub domains routes are created.
Issue
This implementation is having requirement of sub_domain
column from table and which is yet run using migration,
So when I am running migration using php artisan migrate
it's showing me invalid column sub_domain.
This is creating conflict, that To run the migration routes are creating problem, and to prepare proper routes migration needs to be run.
Earlier the same implementation was using .env variables but that was bit tedious as the support of new domains is required.
Can anybody have solution to run migration without interfering Routes
?