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

forContest()

Last updated 2 years ago.
0

Nope, no go. Tried naming it scopeTest() and trying $players->contest->test(), still undefined method:

Call to undefined method Illuminate\Database\Eloquent\Collection::test()

Last updated 2 years ago.
0
Solution
$players->contest()->test()->get();


$players->contest; // shortcut for $players->contest()->get();
Last updated 2 years ago.
0

Doh. Yeah, parantheses on $player->results() was the issue.

I'm coming from Ruby where we don't have to deal with this "methods are different from attributes" stuff. Didn't even notice the use of parentheses in the documentation for query scopes.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jsvensson jsvensson Joined 13 Mar 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.