Initial commit
This commit is contained in:
33
database/seeders/CountriesWwlSeeder.php
Normal file
33
database/seeders/CountriesWwlSeeder.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\CountryWwl;
|
||||
|
||||
class CountriesWwlSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
CountryWwl::truncate();
|
||||
$heading = true;
|
||||
$input_file = fopen(base_path("database/seeders/countries_wwl.csv"), "r");
|
||||
while (($record = fgetcsv($input_file, 10000, ";", '"', '\\')) !== FALSE)
|
||||
{
|
||||
if (!$heading)
|
||||
{
|
||||
$wwl = array(
|
||||
"country_name" => $record['0'],
|
||||
"wwl" => $record['1']
|
||||
);
|
||||
CountryWwl::create($wwl);
|
||||
}
|
||||
$heading = false;
|
||||
}
|
||||
fclose($input_file);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user