-
-
Notifications
You must be signed in to change notification settings - Fork 144
Labels
Description
I've always been confused with what $inversePropertyName, $inverseClassName, and $localPropertyName mean within the context of ORM relations. What if we introduced a more human-readable approach?
final class Book
{
#[BelongsTo('books.author_uuid = authors.uuid')]
public ?Author $author = null;
/** @var \App\Chapter[] */
#[HasMany('chapters.book_uuid = books.uuid')]
public array $chapters = [];
}We can parse that string easily into the right parts. To me that makes much more sense than:
final class Book
{
#[BelongsTo(localPropertyName: 'author_uuid', inversePropertyName: 'uuid')]
public ?Author $author = null;
/** @var \App\Chapter[] */
#[HasMany(inversePropertyName: 'book_uuid', localPropertyName: 'uuid')]
public array $chapters = [];
}