PHP code example of amjadiqbal / laravel-notification-inbox
1. Go to this page and download the library: Download amjadiqbal/laravel-notification-inbox library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amjadiqbal / laravel-notification-inbox example snippets
use Illuminate\Support\Facades\Gate;
Gate::define('viewNotificationInbox', fn ($user) => $user?->is_admin);
Gate::define('manageNotificationInbox', fn ($user) => $user?->is_admin); // delete and clear
use AmjadIqbal\NotificationInbox\Facades\NotificationInbox;
it('tells the customer their order shipped', function () {
NotificationInbox::fake();
$user->notify(new OrderShipped($order));
NotificationInbox::assertCaptured(OrderShipped::class)
->assertCapturedOn('telegram', fn ($n) => str_contains($n->body(), 'A-1042'))
->assertCapturedFor($user)
->assertCapturedFor('+447700900123') // a route: phone number, chat id, channel id
->assertCapturedContaining('Track parcel', 'slack')
->assertNoCaptureErrors(); // every toX() built without throwing
});
// config/notification-inbox.php
'channels' => [
App\Channels\WhatsAppChannel::class => [
'label' => 'WhatsApp',
'method' => 'toWhatsApp', // what your channel calls on the notification
'route' => 'whatsapp', // the routeNotificationFor() key it reads
'preview' => 'sms', // push, slack, teams, telegram, discord, sms, broadcast or json
],
],