PHPackages                             besanek/laravel-firebase-notifications - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. besanek/laravel-firebase-notifications

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

besanek/laravel-firebase-notifications
======================================

Thin layer for integrate Firebase Messaging as Laravel Notifications

v5.0.0(2mo ago)038.8k↓38.5%1BSD-3-ClausePHPPHP ^8.2

Since Jun 26Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/besanek/laravel-firebase-notifications)[ Packagist](https://packagist.org/packages/besanek/laravel-firebase-notifications)[ RSS](/packages/besanek-laravel-firebase-notifications/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (13)Used By (0)

Laravel Firebase Notifications
==============================

[](#laravel-firebase-notifications)

Thin layer for integrate Firebase Messaging as Laravel Notifications

Requirement
-----------

[](#requirement)

- PHP &gt;= 8.1
- Laravel = 10.x

Installing
----------

[](#installing)

```
$ composer require "besanek/laravel-firebase-notifications"
```

This is all, thanks to the Package Autodiscover.

Setup
-----

[](#setup)

Please follow configuration guide of [kreait/laravel-firebase](https://github.com/kreait/laravel-firebase#configuration)

Basic Usage
-----------

[](#basic-usage)

Add new method `routeNotificationForFirebase` to your notifiable entity, witch returns device id.

```
    /**
     * It could be one device
     */
    public function routeNotificationForFirebase()
    {
        return $this->device_id;
    }

    /**
     * Or you can return array for multicast
     */
    public function routeNotificationForFirebase()
    {
        return $this->devices()->get()->pluck('id');
    }
```

In Notification entity you should add *firebase* to `via()` method.

```
    public function via(): array
    {
        return ['firebase', /* 'email', 'database', 'etc...'*/];
    }
```

And you can construct `CloudMessage` into `toFirebase()` method.

```
    public function toFirebase(): Messaging\CloudMessage
        $notification = Messaging\Notification::create('I
