I'm trying to implement slack notifications on my laravel project.
Inside my controller I call:
$user->notify(new WorkAdded());
Here the WorkAdded
class
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
return (new SlackMessage)
->content('TEST');
}
In the User
class I've added:
use Notifiable;
public function routeNotificationForSlack($notification)
{
return 'https://hooks.slack.com/services/...';
}
But when I call the notify function I get the following error:
Type error: Too few arguments to function App\User::routeNotificationForSlack(), 0 passed in /Applications/MAMP/htdocs/gest/vendor/laravel/framework/src/Illuminate/Notifications/RoutesNotifications.php on line 30 and exactly 1 expected
routeNotificationForSlack()
is called, you're not passing a parameter with it, that's why you're getting an error that says 0 passed, expected 1. – user5283119