chartOfAccountRepository = $chartOfAccountRepository; $this->serviceCategoryRepository = $serviceCategoryRepository; } /** * Run the database seeds. * * @return void */ public function run() { ImportSeeder::import('chart_of_accounts', function ($chartOfAccounts) { foreach ($chartOfAccounts as $chartOfAccount) { $parent = ChartOfAccount::where('import_id', $chartOfAccount->parent_id)->first(); $this->chartOfAccountRepository->create( (new ChartOfAccountAttr) ->setType($chartOfAccount->account_type) ->setName($chartOfAccount->account_name) ->setCode($chartOfAccount->account_code) ->setDescription($chartOfAccount->description) ->setDebits($chartOfAccount->debits) ->setCredits($chartOfAccount->credits) ->setChartOfAccountId($parent->id ?? null) ->setImportId($chartOfAccount->id) ); } }); } }