What are the common data types supported in Laravel migrations?

Support Laravel Version: Laravel 8, Laravel 9, Laravel 10, Laravel 11 With Latest All Version Support.

In Laravel migrations, you can use a variety of data types to define the structure of your database tables. Here are some of the common data types supported in Laravel migrations along with examples:

1. String: Used for character string data types.

$table->string('name');

2. Integer: Used for integer data types.

$table->integer('age');

3. Big Integer: Similar to the integer data type but can hold larger values.

$table->bigInteger('views');

4. Float: Used for floating-point number data types.

$table->float('price');

5. Double: Used for double-precision floating-point number data types.

$table->double('amount', 8, 2); // (total digits, decimal digits)

6. Decimal: Used for decimal number data types.

$table->decimal('total', 8, 2); // (total digits, decimal digits)

7. Boolean: Used for boolean (true/false) data types.

$table->boolean('is_active');

8. Text: Used for longer text data types.

$table->text('description');

9. Date: Used for date data types.

$table->date('birthdate');

10. DateTime: Used for date and time data types.

$table->dateTime('created_at');

11. Time: Used for time data types.

$table->time('start_time');

12. Timestamp: Used for timestamps (created_at, updated_at).

$table->timestamps();

13. Binary: Used for binary data types.

$table->binary('data');

14. JSON: Used for storing JSON data.

$table->json('meta_data');

15. UUID: Used for universally unique identifier data types.

$table->uuid('uuid');

These are some of the common data types supported in Laravel migrations. You can use these data types to define the columns in your database tables according to your application’s requirements.