Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anderking's avatar

How can I validate in my request or my controller the non-insertion of a record with compound keys?

I have a many-to-many table of 'cost' with its autoincrementable id, but it also has as foreign keys the id_item and the id_proveedor, as I can avoid that a duplicate record with those combined foreign values is inserted.

0 likes
1 reply
Web Confection's avatar
Level 3

@anderking Eloquent doesn't support composite keys out the box. I would suggest inside your controller or by using middleware assigned to a route

Please or to participate in this conversation.