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

How to get orders for a user? #390

Open
gvanto opened this issue Sep 21, 2021 · 2 comments
Open

How to get orders for a user? #390

gvanto opened this issue Sep 21, 2021 · 2 comments
Assignees
Labels

Comments

@gvanto
Copy link

gvanto commented Sep 21, 2021

/** @var \RainLab\User\Models\User User $user */
        $user = Auth::getUser();

$order = $user->orders()->first(); // this doesn't work even though orders table has user_id relation
@kharanenka
Copy link
Contributor

Hi! \RainLab\User\Models\User model has order relation, not orders

$order = $user->order()->first();

@kharanenka kharanenka self-assigned this Sep 22, 2021
@gvanto
Copy link
Author

gvanto commented Sep 22, 2021

Thanks that works (but has-many relations should be plural right? A user can have many orderS ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants