Created
May 31, 2018 01:23
-
-
Save mabuak/b7421d0d24e5ce24921fe84f31ffb9dc to your computer and use it in GitHub Desktop.
Seed Raw SQL file in laravel
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
<?php | |
use Illuminate\Database\Seeder; | |
class CountrySeeder extends Seeder | |
{ | |
/** | |
* Run the database seeds. | |
* | |
* @return void | |
*/ | |
public function run() | |
{ | |
Eloquent::unguard(); | |
$filePath = database_path('raw/countries.sql'); | |
if(File::exists($filePath)){ | |
DB::unprepared(file_get_contents($filePath)); | |
$this->command->info('Country Table Seed'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment