Hello Devs, 

In this tutorial, we will learn How to Run SQL File or query In Laravel Seeder?

Follow this step-by-step guide below. 

Example :

Create Seeder :

php artisan make:seeder SqlFileSeeder



use Illuminate\Database\Seeder;

class SqlFileSeeder extends Seeder
     * Run the database seeds.
     * @return void
    public function run()

        $path = public_path('sql/File.sql');
        $sql = file_get_contents($path);


Run Seeder:

php artisan db:seed --class=SqlFileSeeder

May this example help you.