$ composer require osp-pawan/pusherbyrepository
Register provider and facade on your config/app.php
file.
'providers' => [
...,
OspPawan\PusherByRepository\PusherByRepositoryServiceProvider::class,
//Uncomment below line from your `config/app.php`
App\Providers\BroadcastServiceProvider::class,
]
When Composer is done, we will need to configure Laravel to use Pusher as its broadcast driver, to do this, open the .env
file that is in the root directory of your Laravel installation. Update the values to correspond with the configuration below:
BROADCAST_DRIVER=pusher
// Get the credentials from your pusher dashboard
PUSHER_APP_ID=XXXXX
PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXX
PUSHER_APP_SECRET=XXXXXXX
Must use below constructor in order to use PusherRepository
<?php
use OspPawan\PusherByRepository\PusherRepository;
private $pusherRepository;
public function __construct(PusherRepository $pusherRepository){
$this->pusherRepository = $pusherRepository;
}
Send boadcast notification to every user by using below line in the function
$this->pusherRepository->broadcastNotification('Send you message here');
After sending you Broadcast Notification you can see all the notification here
run php artisan serve --port=8001
and open http://127.0.0.1:8001/test-pusher