Some use the lowest amount like cents, and cast when needed to dollar and cents. I use decimal, and format as needed for display.
Mar 14, 2025
10
Level 1
How to Define a money Data Type in Laravel Migrations for SQL Server?
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!
Please or to participate in this conversation.