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

You don't need to define the onlyActive and onlyOwner functions as static. Remove the static keyword from the function definition and that'll solve the problem.

The static calls you often see are actually done via the Facades (http://laravel.com/docs/facades) - so, that's likely why you're thinking you need to define functions as static.

Last updated 2 years ago.
0

Hello and thank you for quick reply, I have tried that already here is error provided to me

Non-static method User::onlyOwner() should not be called statically, assuming $this from incompatible context

and the line that is causing this

$users = User::onlyOwner( $id )->onlyActive()->sortable()->paginate(10);
Last updated 2 years ago.
0
Solution

Scopes are made for this use case.

Last updated 2 years ago.
0

Yes I figured out (myself, you "approved"). Thanks.

The big problem with Laravel that I can not stand is no one is "telling me" where (in what file) to put what, where should be all my scopes stored? where should I save facades etc...

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Kyslik kyslik Joined 23 Jul 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.