Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

when you use () it compounds with Query Builder and lets you continue query operations on the next item... When you do not, it pulls the relationship instead...

Auth::User()->organization->id;

Auth::User()->organization()->where('organization_id', 1)->get();

Last updated 2 years ago.
0

Okay. Thanks!

In this case using the query builder wouldn't make much sense, but if it's a many-to-many or hasmany relationship it would.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

skovmand skovmand Joined 27 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.