Thursday, March 16, 2017

Eloquent Laravel Many to many with foreign key not primary

I have some issues with Eloquent Laravel Many to Many model.

I want to use the method belongsToMany in laravel but with keys that are not primary keys, just unique.

Here's my tables :

table1 :

  • id (PM)
  • spec. 1
  • spec. 2

table2 :

  • id (PM)
  • spec. 1
  • spec. 2
  • desc (Unique)

table1_table2 :

  • table1_id
  • table2_desc (PM = union of table1_id and table2)

Is this possible in Laravel to use belongsToMany ?



via EkinOf

Advertisement