31 lines
761 B
PHP
31 lines
761 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class ProvinceWardSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$path = database_path('province_ward_import.sql');
|
|
|
|
if (File::exists($path)) {
|
|
// Read and execute the SQL file
|
|
$sql = File::get($path);
|
|
|
|
// Execute the SQL commands
|
|
DB::unprepared($sql);
|
|
|
|
$this->command->info('Province/Ward data imported successfully from SQL file.');
|
|
} else {
|
|
$this->command->error('File database/province_ward_import.sql not found.');
|
|
}
|
|
}
|
|
}
|