check(); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); $this->check(); } } } private function check() { Company::cursor()->each(function ($company) { if($company->invoices->count() > 1000 || $company->products->count() > 1000 || $company->clients->count() > 1000) { $company->is_large = true; $company->save(); } }); } }