handleOnDb(); } else { //multiDB environment, need to foreach (MultiDB::$dbs as $db) { MultiDB::setDB($db); $this->handleOnDb(); } MultiDB::setDB($current_db); } } private function handleOnDb() { foreach (Design::whereIsCustom(false)->get() as $design) { $invoice_design = new \App\Services\PdfMaker\Design(strtolower($design->name)); $invoice_design->document(); $design_object = new stdClass(); $design_object->includes = $invoice_design->getSectionHTML('style'); $design_object->header = $invoice_design->getSectionHTML('header'); $design_object->body = $invoice_design->getSectionHTML('body'); $design_object->product = ''; $design_object->task = ''; $design_object->footer = $invoice_design->getSectionHTML('footer'); $design->design = $design_object; $design->save(); } } }