How do I load the user_id and the sensitivedata_id, in my pivor table, I thaught I had set up every thing accordingly but I have issue with setting up the foreign key I think
I want to set up a many to many relationship between databases in laravel.
I created a two models where by the pivot table suppose to get the id from. But when I load data to the database the pivot table stays empty.
Here is my code: migration file
/** * Run the migrations. * * @return void */ public function up() { Schema::create('sensitivedata_user', function (Blueprint $table) { $table->id(); $table->integer('user_id'); $table->integer('creditcard_id'); $table->timestamps(); }); }
Getting error trying to use foreignid and constrainted method
and migrate it to the database
Chris Stanyon
Hey there,
I can't quite read your screen shot, but from your migrations list, it looks like you're trying to setup the foreign keys before you've created the CreditCard table - that mirgation is set to run AFTER your pivot table migration (they run in date order), so it can't create the index. Just rename either of those 2 migrations to change the order they run (just change the time part of it:
2021_06_08_200649_create_users ...
Just change that bit to be later that 201625 and then re-run your migrations
and migrate it to the database