PHP code example of pxlrbt / laravel-notification-preview
1. Go to this page and download the library: Download pxlrbt/laravel-notification-preview 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/ */
pxlrbt / laravel-notification-preview example snippets
// config/notification-preview.php
return [
'enabled' => env('NOTIFICATION_PREVIEW_ENABLED', true),
// The kinds of classes to look for. Turn either off to skip it entirely.
'notifications' => env('NOTIFICATION_PREVIEW_NOTIFICATIONS', true),
'mailables' => env('NOTIFICATION_PREVIEW_MAILABLES', true),
'url_prefix' => env('NOTIFICATION_PREVIEW_URL_PREFIX', 'dev/notifications'),
'middleware' => ['web'],
// Directories, scanned recursively.
'paths' => [
app_path('Notifications'),
app_path('Mail'),
],
// Class names and namespaces to hide.
'exclude' => [],
// null falls back to the directories inside lang_path()
'locales' => null,
'test_email' => env('NOTIFICATION_PREVIEW_TEST_EMAIL'),
];
'channels' => ['mail', 'database', 'smsapi'],
use pxlrbt\LaravelNotificationPreview\Facades\NotificationPreview;
// Local machines only.
NotificationPreview::auth(fn () => app()->isLocal());
// Or specific people, wherever they are.
NotificationPreview::auth(fn (?Request $request) => $request?->user()?->isAdmin());
'exclude' => [
App\Notifications\Internal\DebugPing::class, // one class
'App\Notifications\Internal', // the whole namespace
],
use pxlrbt\LaravelNotificationPreview\Facades\NotificationPreview;
NotificationPreview::resolve(Order::class, fn () => Order::factory()->make(['id' => 1]));
use pxlrbt\LaravelNotificationPreview\Preview;
use pxlrbt\LaravelNotificationPreview\Variant;
class OrderShipped extends Notification
{
public static function preview(Preview $preview): void
{
$preview
->label('Shipping confirmation')
->group('Orders')
->variants([
Variant::make('express', fn () => new self(Order::factory()->express()->make())),
Variant::make('standard', fn () => new self(Order::factory()->make())),
]);
}
}
NotificationPreview::register(SomePackage\Notifications\Welcome::class);
// Same matching rules as the `exclude` config key.
NotificationPreview::exclude(InternalDebugNotification::class);
NotificationPreview::exclude('App\Notifications\Internal');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.