Skip to content

Instantly share code, notes, and snippets.

@mabuak
Created May 31, 2018 01:23
Show Gist options
  • Save mabuak/b7421d0d24e5ce24921fe84f31ffb9dc to your computer and use it in GitHub Desktop.
Save mabuak/b7421d0d24e5ce24921fe84f31ffb9dc to your computer and use it in GitHub Desktop.
Seed Raw SQL file in laravel
<?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