jeudi 25 avril 2019

Get Duplicates in Eloquent Pivot Table

I have a pivot table that joins two models, let's call them Item and Place.

INSERT INTO `COLUMNS` (`Field`, `Type`, `Null`, `Key`, `Default`, `Extra`) VALUES 
    ('item_id','int(10) unsigned','NO','MUL',NULL,NULL),
    ('place_id','int(10) unsigned','NO','MUL',NULL,NULL);


I need to be able to run a query that will show me all the duplicates where a row has the same item_id and place_id

In other words, an item may have only one instance of the same place.

So item_id 6 and place_id 200 may only occur once in the table.

Places is a many to many relationship on the Item model, so ideally building out this query in Eloquent would be the best solution.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire