hocza / sendy-laravel

A service provider for Sendy API in Laravel 5
https://hocza.com/packages/sendy/
MIT License
71 stars 21 forks source link

I can call the function as static #13

Closed closerdesign closed 5 years ago

closerdesign commented 8 years ago

Hi guys,

I'm trying to use the library following your instructions but at the end, the only response that I have is that I'm trying to call a method statically that can't be called that way. Any idea?

alisonmonteiro commented 8 years ago

Hi, @closerdesign How are you? Could you, please, post your code here? I mean, the part which is causing this error.

Tks!

closerdesign commented 8 years ago

Thanks!

I'm having to do this:

$sendy = new Sendy([ 'listId' => 'MyListId', 'installationUrl' => 'MyUrl', 'apiKey' => 'MyApiKey' ]);

$sendy->subscribe([ 'email' => $request->email ]);

Instead of this:

$data = [ 'email' => 'johndoe@example.com', 'name' => 'John Doe', 'any_custom_column' => 'value'];Sendy::subscribe($data);

On Tue, Jul 19, 2016 at 8:08 PM Alison Monteiro notifications@github.com wrote:

Hi, @closerdesign https://github.com/closerdesign How are you? Could you, please, post your code here? I mean, the part which is causing this error.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hocza/sendy-laravel/issues/13#issuecomment-233811544, or mute the thread https://github.com/notifications/unsubscribe-auth/AKhLeH6xlTe252V-NThpM2-8MuU4B943ks5qXXUZgaJpZM4JQU2K .

hocza commented 8 years ago

Huh next time hide your API key.

So the first snippet is working but the below one is not working?

Did you setup the config/sendy.php correctly?

closerdesign commented 8 years ago

Yes. And there is no problem at that point. The thing is that is I use the function as static it doesn't work. If I use the function as dynamic it simply ignores the sendy.php.

alisonmonteiro commented 8 years ago

@closerdesign To use the method as static you need add an alias on config/app.php

'aliases' => [
    // ...
    'Sendy' => 'Hocza\Sendy\Facades\Sendy',
]

Did you do that?

closerdesign commented 8 years ago

Yes, I did. It didn´t work. I followed the instructions exactly as they are on the site.

A question comes up with this, what´s the difference between these formats on service providers?

'View' => Illuminate\Support\Facades\View::class, 'Sendy' => 'Hocza\Sendy\Facades\Sendy',

Do I have to call Sendy the same way as View?

Thanks dude!

juanmrad commented 6 years ago

@closerdesign if you still might have the issue I was able to fix it by doing: use Hocza\Sendy\Facades\Sendy; Instead and then call the functions statically. It complains in php storm that the function doesn't exist but it works fine.