Livewire Mount GuzzleHelper Class Not Working

Viewed 156

Hey all you smart people i'm having a small issue when tyring to use Livewire.

If I was using Laravel I would normally use the __construct() to injects my Guzzle Helper for all my Guzzle requests, however with Livewire i'm having a few issues and was wondering if anyone can help me.

This is an example of my component

class RegistrationLogin extends Component
{
    protected $guzzleHelper;

    public function mount(GuzzleHelper $guzzleHelper)
    {
        $this->guzzleHelper = $guzzleHelper;
    }
}

Here is an example of my GuzzleHelper Class

class GuzzleHelper
{
    /**
     * @var Client
     */
    protected $client;

    /**
     * GuzzleHelper constructor.
     * @param Client $client
     */
    public function __construct(Client $client)
    {
        $this->client = $client;
    }

    /**
     * @param string $example
     * @return object
     * @throws GuzzleException
     */
    public function example(array $paramsData)
    {
        $client = $this->client;
        $URI = env('URL');

        $params['headers'] = [
            'Accept' => 'application/json',
        ];

        $params['json'] = [
            "name" => $paramsData['name'],
            "email" => $paramsData['email'],
            "password" => $paramsData['password']
        ];

        return $this->responsePost($client, $URI, $params);
    }

However when I try to add this into my component

$helper = $this->guzzleHelper->example($data);

it doesn't know what example is and I just get an error even thou its there :-/, I'm not sure if i'm missing something or just doing it all wrong.

I appreciate any help that anyone could help me with....

0 Answers
Related