Search
 
SCRIPT & CODE EXAMPLE
 

PHP

migration types in laravel

/*
|========================================================
| Common Migration Types in (for mySql) Laravel
|========================================================
*/
$table->bigIncrements('id'); 	Incrementing ID using a "big integer" equivalent.
$table->bigInteger('votes'); 	BIGINT equivalent to the table
$table->binary('data'); 	BLOB equivalent to the table
$table->boolean('confirmed'); 	BOOLEAN equivalent to the table
$table->char('name', 4); 	CHAR equivalent with a length
$table->date('created_at'); 	DATE equivalent to the table
$table->dateTime('created_at'); 	DATETIME equivalent to the table
$table->decimal('amount', 5, 2); 	DECIMAL equivalent with a precision and scale
$table->double('column', 15, 8); 	DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point
$table->enum('choices', array('foo', 'bar')); 	ENUM equivalent to the table
$table->float('amount'); 	FLOAT equivalent to the table
$table->increments('id'); 	Incrementing ID to the table (primary key).
$table->integer('votes'); 	INTEGER equivalent to the table
$table->longText('description'); 	LONGTEXT equivalent to the table
$table->mediumInteger('numbers'); 	MEDIUMINT equivalent to the table
$table->mediumText('description'); 	MEDIUMTEXT equivalent to the table
$table->morphs('taggable'); 	Adds INTEGER taggable_id and STRING taggable_type
$table->nullableTimestamps(); 	Same as timestamps(), except allows NULLs
$table->smallInteger('votes'); 	SMALLINT equivalent to the table
$table->tinyInteger('numbers'); 	TINYINT equivalent to the table
$table->softDeletes(); 	Adds deleted_at column for soft deletes
$table->string('email'); 	VARCHAR equivalent column
$table->string('name', 100); 	VARCHAR equivalent with a length
$table->text('description'); 	TEXT equivalent to the table
$table->time('sunrise'); 	TIME equivalent to the table
$table->timestamp('added_on'); 	TIMESTAMP equivalent to the table
$table->timestamps(); 	Adds created_at and updated_at columns
$table->rememberToken(); 	Adds remember_token as VARCHAR(100) NULL
->nullable() 	Designate that the column allows NULL values
->default($value) 	Declare a default value for a column
->unsigned() 	Set INTEGER to UNSIGNED
Comment

laravel migration integer

$table->integer('votes');
Comment

laravel migration update table column type

Schema::table('users', function ($table) {
    $table->string('name', 50)->change();
});
We could also modify a column to be nullable:

Schema::table('users', function ($table) {
    $table->string('name', 50)->nullable()->change();
});
Comment

laravel migration integer

$table->bigInteger('votes');
Comment

laravel migration column types

# nullableTimestamps()
## alias of the timestamps method
	$table->nullableTimestamps(0);

# nullableMorphs()
## The method is similar to the morphs method 
## however, the columns that are created will be "nullable":
	$table->nullableMorphs('taggable');

# nullableUuidMorphs()
## The method is similar to the uuidMorphs method
## however, the columns that are created will be "nullable":
    $table->nullableUuidMorphs('taggable');

# point()
## creates a POINT equivalent column:
    $table->point('position');

# polygon()
## creates a POLYGON equivalent column:
    $table->polygon('position');

# rememberToken()
## creates a nullable, VARCHAR(100) equivalent column 
## that is intended to store the current "remember me" authentication token:
    $table->rememberToken();

# set()
## creates a SET equivalent column with the given list of valid values:
    $table->set('flavors', ['strawberry', 'vanilla']);

# smallIncrements()
## creates an auto-incrementing UNSIGNED SMALLINT 
## equivalent column as a primary key:
    $table->smallIncrements('id');

# smallInteger()
## creates a SMALLINT equivalent column:
    $table->smallInteger('votes');

# softDeletesTz()
## adds a nullable deleted_at TIMESTAMP (with timezone) equivalent column 
## with an optional precision (total digits). 
## This column is intended to store the deleted_at timestamp 
## needed for Eloquent's "soft delete" functionality:
    $table->softDeletesTz($column = 'deleted_at', $precision = 0);

# softDeletes()
## adds a nullable deleted_at TIMESTAMP 
## equivalent column with an optional precision (total digits). 
## This column is intended to store the deleted_at timestamp 
## needed for Eloquent's "soft delete" functionality:
    $table->softDeletes($column = 'deleted_at', $precision = 0);

# string()
## creates a VARCHAR equivalent column of the given length:
    $table->string('name', 100);

# text()
## creates a TEXT equivalent column:
    $table->text('description');

# timeTz()
## creates a TIME (with timezone) 
## equivalent column with an optional precision (total digits):
    $table->timeTz('sunrise', $precision = 0);

# time()
## creates a TIME equivalent column with an optional precision (total digits):
    $table->time('sunrise', $precision = 0);

# timestampTz()
## creates a TIMESTAMP (with timezone) 
## equivalent column with an optional precision (total digits):
    $table->timestampTz('added_at', $precision = 0);

# timestamp()
## creates a TIMESTAMP equivalent column 
## with an optional precision (total digits):
    $table->timestamp('added_at', $precision = 0);

# timestampsTz()
## creates created_at and updated_at TIMESTAMP 
## (with timezone) equivalent columns with an optional precision (total digits):
    $table->timestampsTz($precision = 0);

# timestamps()
## creates created_at and updated_at TIMESTAMP 
## equivalent columns with an optional precision (total digits):
    $table->timestamps($precision = 0);

# tinyIncrements()
## creates an auto-incrementing UNSIGNED TINYINT 
## equivalent column as a primary key:
    $table->tinyIncrements('id');

# tinyInteger()
## creates a TINYINT equivalent column:
    $table->tinyInteger('votes');

# tinyText()
## creates a TINYTEXT equivalent column:
    $table->tinyText('notes');

# unsignedBigInteger()
## creates an UNSIGNED BIGINT equivalent column:
    $table->unsignedBigInteger('votes');

# unsignedDecimal()
## creates an UNSIGNED DECIMAL equivalent column with 
## an optional precision (total digits) 
## and scale (decimal digits):
    $table->unsignedDecimal('amount', $precision = 8, $scale = 2);

# unsignedInteger()
## creates an UNSIGNED INTEGER equivalent column:
    $table->unsignedInteger('votes');

# unsignedMediumInteger()
## creates an UNSIGNED MEDIUMINT equivalent column:
    $table->unsignedMediumInteger('votes');

# unsignedSmallInteger()
## creates an UNSIGNED SMALLINT equivalent column:
    $table->unsignedSmallInteger('votes');

# unsignedTinyInteger()
## creates an UNSIGNED TINYINT equivalent column:
    $table->unsignedTinyInteger('votes');

# uuidMorphs()
## The uuidMorphs method is a convenience method that adds a 
## {column}_id CHAR(36) equivalent column and a {column}_type 
## VARCHAR equivalent column.
## This method is intended to be used when defining the columns necessary 
## for a polymorphic Eloquent relationship that use UUID identifiers. 
## In the following example, `taggable_id` and `taggable_type` columns would be created:
    $table->uuidMorphs('taggable');

# uuid()
## creates a UUID equivalent column:
    $table->uuid('id');

# year()
## creates a YEAR equivalent column:
    $table->year('birth_year');
Comment

number data type in laravel migration

laravel migration types
Comment

laravel migration type to store html

$table->text('content');
Comment

data types of laravel migrations

select count(*) as aggregate from `categories` where `title` = jncisudrf
Comment

laravel Database migrations column types

$table->geometry('positions');
$table->ipAddress('visitor');
$table->macAddress('device');
$table->point('position');
$table->uuid('id');
Comment

PREVIOUS NEXT
Code Example
Php :: php while loop of alphabet 
Php :: mysql count rows php 
Php :: while loop php 
Php :: wp enqueue style for style.css 
Php :: mysql get the last id php 
Php :: how to retrieve value from stdclass array in php 
Php :: curl exec not working php 
Php :: php base64img to file 
Php :: get order details by id woocommerce 
Php :: laravel transform object to array 
Php :: laravel date set timezone 
Php :: publish config laravel 
Php :: Skip WooCommerce Cart page and redirect to Checkout page 
Php :: unable to locate package php8.1 ubuntu 
Php :: laravel migration remove unique 
Php :: Session store not set on request. 
Php :: mysqli php 7.4 
Php :: http error code php 
Php :: How to pass JavaScript variables to PHP? 
Php :: sort laravel eloquent 
Php :: laravel token logout 
Php :: how do decode base64 php 
Php :: max_execution_time php 
Php :: php print array new line 
Php :: laravel form validation 
Php :: php curl async callback 
Php :: upload pdf file in laravel 
Php :: To find out where your php.ini is located 
Php :: php timer 
Php :: php find string in string 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =