Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Relation attributes #756

Closed
4 tasks
brendt opened this issue Nov 20, 2024 · 2 comments
Closed
4 tasks

Model Relation attributes #756

brendt opened this issue Nov 20, 2024 · 2 comments

Comments

@brendt
Copy link
Member

brendt commented Nov 20, 2024

Currently we have a HasOne attribute that allows you to define and optionally override the inverse relation of BelongsTo.

We need attributes for other types of relations as well though, to make sure that users have to ability to override Tempest's default relation inference.

  • #[BelongsTo('inverseName')]
  • #[HasMany('inverseName')]

Optionally, we may allow something like this:

class Book
{
    #[BelongsTo('books.author_id', 'authors.id')]
    public Author $author;

    // …
}

This would be in line with how migrations handle relations.

These attributes shouldn't be used by default, but should be available to solve the edge cases.

Docs:

  • Document these attributes
  • Document relation loading via the query builder
@brendt brendt added this to the v1.0.0-alpha.5 milestone Nov 20, 2024
@brendt brendt modified the milestones: v1.0.0-alpha.5, pre-1.0 Nov 27, 2024
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Dec 28, 2024
Copy link

This issue was closed because it has been inactive for 1 day since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant