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

Non-static method #18

Closed
saleamp opened this issue Sep 11, 2014 · 6 comments
Closed

Non-static method #18

saleamp opened this issue Sep 11, 2014 · 6 comments

Comments

@saleamp
Copy link

saleamp commented Sep 11, 2014

I'm trying to use the example in the README but this is what returns:

Non-static method Thujohn\Analytics\Analytics::getSiteIdByUrl() should not be called statically, assuming $this from incompatible context

@rayne128
Copy link

Did you try adding this in your config/app.php?

         'providers' => array(
            ...
            'Thujohn\Analytics\AnalyticsServiceProvider'
        );

        'aliases' => array(
            ...
            'Analytics' => 'Thujohn\Analytics\AnalyticsFacade'
        );

Then you can just use the method by Analytics::getAllSitesIds();

@saleamp
Copy link
Author

saleamp commented Sep 11, 2014

Yes, I have those in my app.php file. This is the code I'm trying to run:

...
use Thujohn\Analytics\Analytics;

class GoogleController extends AdminController {

    public static function analytics() {

        $sites = Analytics::getAllSitesIds();

        return $sites;

    }
...

Then calling it in a blade file:

$results = GoogleController::analytics();

print_r($results);

@rayne128
Copy link

Try removing
use Thujohn\Analytics\Analytics;
on your GoogleController class

@saleamp
Copy link
Author

saleamp commented Sep 12, 2014

I did, but it's looking for the class in my extension. For example:

Class '<Extension>\<Extension Name>\Controllers\Admin\Analytics' not found

@thujohn
Copy link
Owner

thujohn commented Sep 12, 2014

You need to use the facade

use \Thujohn\Analytics\AnalyticsFacade as Analytics;

or just

use \Analytics;

@saleamp
Copy link
Author

saleamp commented Sep 12, 2014

That works. Thanks!

@saleamp saleamp closed this as completed Sep 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants