I'm working with Laravel migrations and need to define a money column type in SQL Server. However, Laravel's schema builder does not provide a direct money type.
I’ve considered two approaches:
Using raw SQL:
Schema::table('your_table', function (Blueprint $table) {
DB::statement("ALTER TABLE your_table ADD price MONEY");
});
Using decimal as an alternative:
Schema::table('your_table', function (Blueprint $table) {
$table->decimal('price', 19, 4);
});
I prefer a solution that works natively with Laravel’s schema builder. Is there a way to register a custom column type for money, or is raw SQL the only option?
Any recommendations for best practices in Laravel with SQL Server are appreciated!