mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-26 16:04:23 +00:00
fix: company seeder create company module along with creating new compaany
This commit is contained in:
@@ -3,10 +3,13 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use App\Classes\ValueObjects\Constants\CompanyType;
|
||||
use App\Classes\ValueObjects\Constants\BusinessType;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyModule;
|
||||
|
||||
class CompaniesTableSeeder extends Seeder
|
||||
{
|
||||
@@ -17,19 +20,36 @@ class CompaniesTableSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('companies')->insert([
|
||||
|
||||
$companies = [
|
||||
[
|
||||
'name' => 'Guang Zhou',
|
||||
'reference' => 'guangzhou',
|
||||
'type' => BusinessType::WAREHOUSE,
|
||||
'reference' => 'guangzhouwarehouse',
|
||||
'type' => CompanyType::COMPANY_BUSINESS,
|
||||
'status' => ApprovalStatus::APPROVED,
|
||||
],
|
||||
[
|
||||
'name' => 'Yiwu',
|
||||
'reference' => 'yiwu',
|
||||
'type' => BusinessType::WAREHOUSE,
|
||||
'reference' => 'yiwuwarehouse',
|
||||
'type' => CompanyType::COMPANY_BUSINESS,
|
||||
'status' => ApprovalStatus::APPROVED,
|
||||
]
|
||||
]);
|
||||
];
|
||||
|
||||
|
||||
if (!empty($companies)) {
|
||||
foreach ($companies as $company) {
|
||||
|
||||
$company = Company::create($company);
|
||||
|
||||
CompanyModule::create(
|
||||
[
|
||||
'company_id' => $company->id,
|
||||
'type' => BusinessType::WAREHOUSE,
|
||||
'status' => ApprovalStatus::APPROVED,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user