zgabievi/laravel-promocodes

Relation table migration

Closed this issue · 1 comments

Describe the bug
If I define user_model that is, say, Customer model in config file, the table migration doesn't use the config file value to create the related table.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'promocodes.php
  2. Modify 'user_model' to use a different table. I use Customer instead of default User table.
  3. When you run 'php artisan migrate' after that, the promocode_user table still refers to Users table in the relationship (fk).

Expected behavior
Migration file should use the 'user_model' property from config("user_model").

This line(35) needs to be updated:
$table->foreign('user_id')->references('id')->on('user);

Versions (please complete the following information):

  • Laravel: [e.g. 5.6]
  • PHP [e.g. 7.2]

Additional context
Add any other context about the problem here.

You can now use vendor:publish to publish migrations and refactor them locally.