Answers for "laravel data type migration"

PHP
21

laravel foreign key

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Posted by: Guest on December-09-2020
1

create database from migration laravel for all

php artisan migrate:refresh

php artisan migrate:refresh --seed
Posted by: Guest on August-05-2020
2

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();
});
Posted by: Guest on July-31-2021
1

create migration laravel

php artisan make:Model Product -m -c  --resource
Posted by: Guest on November-26-2020
0

laravel migration type to store html

$table->text('content');
Posted by: Guest on October-15-2021

Code answers related to "laravel data type migration"

Browse Popular Code Answers by Language