whereNull('subdomain')->orWhere('subdomain', '')->get(); $c2 = Company::on('db-ninja-02')->whereNull('subdomain')->orWhere('subdomain', '')->get(); $c1->each(function ($company) { $company->subdomain = MultiDB::randomSubdomainGenerator(); $company->save(); }); $c2->each(function ($company) { $company->subdomain = MultiDB::randomSubdomainGenerator(); $company->save(); }); } }