PHPackages                             youpi/youpi-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. youpi/youpi-notifications

ActiveLibrary

youpi/youpi-notifications
=========================

A Laravel Nova tool for real time notification.

01PHP

Since May 3Pushed 4y agoCompare

[ Source](https://github.com/youpi-sarl/youpi-notifications)[ Packagist](https://packagist.org/packages/youpi/youpi-notifications)[ RSS](/packages/youpi-youpi-notifications/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Nova youpi-notifications youpi notifications in laravel nova

[![Build Status](https://camo.githubusercontent.com/9c8cee01ba1b99a21483c3a8f1dd8d01c6b16d0b068d3f41840078f38afda286/68747470733a2f2f7472617669732d63692e6f72672f6d69726f7669742f6e6f76612d6e6f74696669636174696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mirovit/nova-notifications)[![Maintainability](https://camo.githubusercontent.com/5d426fb269300fd6d48593f6694eda7858ab5c370fb3a32771c08733f568deef/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62386131383036383462356436346232626561632f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/mirovit/nova-notifications/maintainability)[![Test Coverage](https://camo.githubusercontent.com/b592967ec4a2c67ed940d31172248be627681f3747a677ffd8b705ae1f4804ab/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f62386131383036383462356436346232626561632f746573745f636f766572616765)](https://codeclimate.com/github/mirovit/nova-notifications/test_coverage)

Quick Links
-----------

[](#quick-links)

- [Prerequisites](https://github.com/mirovit/nova-notifications#prerequisites)
- [Installation](https://github.com/mirovit/nova-notifications#installation)
- [Usage](https://github.com/mirovit/nova-notifications#usage)
- [Available methods](https://github.com/mirovit/nova-notifications#available-methods)
- [Icons](https://github.com/mirovit/nova-notifications#icons)
- [Configuration](https://github.com/mirovit/nova-notifications#configuration)
- [Translation](https://github.com/mirovit/nova-notifications#translation)
- [Demo](https://github.com/mirovit/nova-notifications#demo)
- [ToDos](https://github.com/mirovit/nova-notifications#todos)

Prerequisites
-------------

[](#prerequisites)

- Laravel Nova app
- Laravel Broadcasting configured
- Laravel Echo
- Laravel Notifications

Installation
------------

[](#installation)

Install via composer `composer require youpi/youpi-notifications`.

Laravel will auto-register the Service Provider. You'll need to register the tool with Laravel Nova.

```
    public function tools()
    {
        return [
            // ...
            \Youpi\YoupiNotifications\YoupiNotifications::make(),
        ];
    }
```

Make sure you have the user channel authenticated in `routes/channels.php` or where you store this logic:

```
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int)$user->id === (int)$id;
});
```

Laravel Echo is not bundled with Nova by defult, so you will need to setup that for your front end. To do that follow these steps below:

- Install [Echo](https://laravel.com/docs/7.x/broadcasting#installing-laravel-echo)
- `npm install`
- create an admin.js file in resources/js

```
import Echo from 'laravel-echo';
// Sample instance with Pusher
window.Pusher = require('pusher-js');
window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: true
});
```

- add to your webpack.mix.js

```
mix.js('resources/js/admin.js', 'public/js');
```

- add in your Nova layout.blade.php

```
// ...

```

Additionally, the package assumes that models are namespaced as App\\Models, if that is not correct for your project, the authentication between the front &amp; back end will not work and notifications will not show without refreshing the page. Go to the [Configuration](https://github.com/mirovit/nova-notifications#configuration) section to see how to fix this.

The last step is to publish manually Nova's layout file if you haven't done so. `cp vendor/laravel/nova/resources/views/layout.blade.php resources/views/vendor/nova/layout.blade.php`

Then place the partial view that displays the bell icon in the nav bar:

Find in `views/vendor/nova/layout.blade.php`:

```

    @include('nova::partials.user')

```

Replace with:

```
@include('YoupiNotifications::dropdown')

    @include('nova::partials.user')

```

Usage
-----

[](#usage)

Trigger a notification from Laravel. Sample notification:

```
