Laravel Basic
Laravel Form
Laravel Database
Laravel Advance
|
Type |
Description |
|---|---|
|
tinyInteger |
-128 to 127 or 0 to 255 (unsigned) |
|
smallInteger |
-32,768 to 32,767 |
|
integer |
-2,147,483,648 to 2,147,483,647 |
|
bigInteger |
Large range |
|
decimal |
Fixed point (e.g., money) |
|
float |
Floating point |
|
double |
More precision than float |
|
unsigned() |
Makes any integer positive-only |
|
Type |
Description |
|---|---|
|
string |
VARCHAR (default length 255) |
|
char |
Fixed-length string |
|
text |
Long text |
|
mediumText, longText |
Even longer text |
|
Type |
Description |
|---|---|
|
date |
Date only |
|
datetime |
Date & time |
|
timestamp |
Date & time (auto-filled often) |
|
timestamps |
Adds created_at and updated_at |
|
softDeletes |
Adds deleted_at for soft delete |
|
Type |
Description |
|---|---|
|
json |
Stores JSON |
|
uuid |
Universally unique ID |
|
binary |
Binary data |
|
enum |
$table->enum('level', ['basic', 'pro']); |
|
Modifier |
Description |
Example |
|---|---|---|
|
->nullable() |
Allows column to store NULL |
$table->string('name')->nullable(); |
|
->default(value) |
Sets a default value |
$table->boolean('active')->default(true); |
|
->unique() |
Adds a unique constraint |
$table->string('email')->unique(); |
|
->index() |
Adds a basic index |
$table->string('slug')->index(); |
|
->primary() |
Sets the column as primary key |
$table->uuid('id')->primary(); |
|
->after('col') |
Puts this column after another (MySQL only) |
$table->string('token')->after('email'); |
|
->first() |
Makes this the first column (MySQL only) |
$table->string('first_name')->first(); |
|
->change() |
Used when modifying an existing column |
$table->string('title', 500)->nullable()->change(); |
|
->unsigned() |
Makes an integer column unsigned (positive only) |
$table->integer('votes')->unsigned(); |
|
->charset() |
Overrides charset per column (rare) |
$table->string('name')->charset('utf8mb4'); |
|
->collation() |
Overrides collation |
$table->string('name')->collation('utf8mb4_bin'); |
|
->autoIncrement() |
Sets column to auto-increment |
$table->integer('custom_id')->autoIncrement(); |