You can call your stored procedure with an unprepared query:
DB::unprepared('CALL fill_dates("2020-01-01", "2030-12-31")');
Here's how I handle the creation and execution of stored procedures from my migrations (the function is used to populate the dates table with all possible dates for the next 10 years):
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('dates', function (Blueprint $table) {
$table->increments('id');
$table->date('date')->index();
});
DB::unprepared('DROP PROCEDURE IF EXISTS fill_dates');
DB::unprepared('
CREATE PROCEDURE fill_dates(start_date DATE, end_date DATE)
BEGIN
DECLARE crt_date DATE;
SET crt_date = start_date;
WHILE crt_date <= end_date DO
INSERT INTO dates(date) VALUES(crt_date);
SET crt_date = ADDDATE(crt_date, INTERVAL 1 DAY);
END WHILE;
END
');
DB::unprepared('CALL fill_dates("2020-01-01", "2030-12-31")');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}