one-of-many relationships landing today in laravel 8.x

Laravel now supports one-to-one relations that are a partial relation of a larger one-to-many relation.

These are: **hasOne** ∈ hasMany, **morphOne** ∈ morphMany

Here's the pull request: [https://github.com/laravel/framework/pull/37362](https://github.com/laravel/framework/pull/37362)

And here are some examples:

https://preview.redd.it/pqlkdv5d1uz61.png?width=1228&format=png&auto=webp&s=d7b88c09161ffaf4051e7cd3380daee38a2be186

[latest published price for a product](https://preview.redd.it/jrqryzwf1uz61.png?width=1110&format=png&auto=webp&s=9324d537e52de747154e401069a56cea3fe847a0)

[current payment state using morph via stateful](https://preview.redd.it/fbql0jtg1uz61.png?width=1346&format=png&auto=webp&s=440fbe697539ac6e67e81c69828d584ed808c169)

5 thoughts on “one-of-many relationships landing today in laravel 8.x”

  1. This is the sort of thing that when it comes along, you think, how have we coped without this before?

    Loads of use cases and I’m sure we’ll be using it a lot in our projects as soon as we upgrade.

    Reply

Leave a Comment