❄️ The winter sale is here. 25% off for a limited time. Join us →

Laravel
Foreign id can be added to the table in several ways
4
391

akr4m

Started this discussion 1 year ago

You can add foreign id in your table like these easily.

  • This method creates an UNSIGNED BIGINT equivalent column:
$table->foreignId('product_id');
  • This method adds a {column}_id UNSIGNED BIGINT equivalent column for a given model class (my favorite):
$table->foreignIdFor(Product::class);
  • This method creates a UUID equivalent column:
$table->foreignUuid('product_id');

If you have any, please reply.

Haz

Replied 1 year ago

The whole point of this beta is to test the forum and the functionality. I'm not sure if @alex has plans to keep any of the data during this period, so just be aware of that.

alex

Replied 1 year ago

All useful discussions will be kept. I’m not wiping everything. Sorry if that wasn’t clear :)

Haz

Replied 1 year ago

Good to know. Thanks for clarifying! @alex

tisuchi

Replied 1 year ago

@akr4m I think it's all about your design plan.

You can refer to any column as a foreign key.