1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/laravel-migrations-have-a-very-nice-syntax-for-foreign-keys.md
2021-04-06 18:27:18 +02:00

501 B

title tweet_id thread_slug author_username images created_at slug
Laravel migrations have a very nice syntax for foreign keys 1308126491188883463 1-rt-1-tip samuelstancl
2021-04-06T16:07:46+00:00 laravel-migrations-have-a-very-nice-syntax-for-foreign-keys

I didn't know about this for so long.

Instead of: $table->unsignedBigInteger('user_id'); $table->foreign('user_id')->references('id')->on('users');

You do: $table->foreignId('user_id')->constrained();