generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09585e9
commit bc970c5
Showing
3 changed files
with
15 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
<?php | ||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Satusehat\Integration\Models\Icd10; | ||
use JeroenZwart\CsvSeeder\CsvSeeder; | ||
use DB; | ||
|
||
class Icd10Seeder extends Seeder | ||
class Icd10Seeder extends CsvSeeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(){ | ||
$this->file = base_path().'/database/seeders/csv/icd10.csv'; | ||
$this->tablename = config('satusehatintegration.icd10_table_name'); | ||
$this->delimiter = ';'; | ||
} | ||
|
||
public function run() | ||
{ | ||
Icd10::truncate(); | ||
|
||
$csvFile = fopen(database_path("/seeders/csv/icd10.csv"), "r"); | ||
|
||
$firstline = true; | ||
while (($data = fgetcsv($csvFile, 2000, ";")) !== FALSE) { | ||
if (!$firstline) { | ||
Icd10::create([ | ||
"icd10_code" => $data['0'], | ||
"icd10_en" => $data['1'], | ||
"icd10_id" => $data['2'] | ||
]); | ||
} | ||
$firstline = false; | ||
} | ||
// Recommended when importing larger CSVs | ||
DB::disableQueryLog(); | ||
|
||
fclose($csvFile); | ||
parent::run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters