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

Method Make not found #13

Closed
alessandrobelli opened this issue Apr 9, 2020 · 1 comment
Closed

Method Make not found #13

alessandrobelli opened this issue Apr 9, 2020 · 1 comment
Labels
question Further information is requested

Comments

@alessandrobelli
Copy link

[2020-04-09 18:39:13] local.ERROR: Call to undefined method NotificationChannels\RocketChat\RocketChatMessage::make() {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to undefined method NotificationChannels\\RocketChat\\RocketChatMessage::make() at /Users/belli/code/metag_analyze/app/Notifications/UserRegistered.php:43)

Usage:
UserRegistered.php

class UserRegistered extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($details)
    {

        $this->email = $details['email'];
        $this->users =  User::all()->count();
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [
            RocketChatWebhookChannel::class,
        ];
    }

    public function toRocketChat(): RocketChatMessage
    {
        return RocketChatMessage::make('A user registered!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'email' => $this->email,
            'users' => $this->users
        ];
    }
}

then in RegisterController.php

$notification = new UserRegistered(['email' => $data['email']]);
$notification->toRocketChat();
@antonkomarev
Copy link
Collaborator

Hi @alessandrobelli! You are reading README of master branch which is not released yet.

Take a look into stable release:
https://github.com/laravel-notification-channels/rocket-chat/tree/v0.1.0

@antonkomarev antonkomarev added the question Further information is requested label Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants