mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
501 B
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 | 2020-09-21T19:30:33+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();