Level 75
Usually called from controller, you generally need "return".
I have never tried it without return. Also, I'd go with documentation examples no matter.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I was wondering what difference does it make to return the query, i've been working with scopes for a some time and yet to find a difference.
public function scopePublished($query)
{
return $query->where('published', true);
}
vs
public function scopePublished($query)
{
$query->where('published', true);
}
both seems to work quite the same even with chaining multiple scopes
Please or to participate in this conversation.