As the error suggests, the relationship definition uses array_key_exists function behind the scene to check if the key (in this case composite key) exists in the array of foreign keys for the related table. The reason the single key works but not the composite key is because the single key returned is only one value which conforms to how array_key_exists method is defined in php. The composite key on the other hand, returns a multi-dimensional array strucure instead which when passed as an arguement to the array_key_exists method returns that error. You can give this article a read on how to use composite key in your Laravel project.