File manager - Edit - /home/autoph/public_html/projects/tickets-autohub/database/seeders/CompanySeeder.php
Back
<?php namespace Database\Seeders; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\DB; class CompanySeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('companies')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); $companies = DB::connection('autohub_connect')->table('vts_company')->get(); if ($companies->isNotEmpty()) { // Insert each company into the current database foreach ($companies as $company) { DB::table('companies')->insert([ 'id' => $company->comp_id, 'comp_code' => $company->comp_code, 'comp_name' => $company->comp_name, 'address' => $company->comp_address, 'city' => $company->comp_city, 'contact' => $company->comp_contact, 'status' => $company->comp_status, 'created_at' => date('Y-m-d h:i:s') ]); } // Optional: Output the result to console for visibility // $this->command->info(count($companies) . " companies seeded successfully."); } else { // $this->command->warn("No companies found to seed."); } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.11 |
proxy
|
phpinfo
|
Settings