> For the complete documentation index, see [llms.txt](https://pratikdai404.gitbook.io/adminetic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pratikdai404.gitbook.io/adminetic/addons/notify.md).

# Notify

Notification module for Adminetic Admin Panel

## Notification Module for Adminetic Admin Panel

<figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2FHagO5Oo6QUBPBXJ56rmn%2Fbanner.jpg?alt=media&amp;token=ac1a059a-82c5-4779-a04c-050642af169a" alt=""><figcaption></figcaption></figure>

[![Latest Version on Packagist](https://img.shields.io/packagist/v/adminetic/notify.svg?style=flat-square)](https://packagist.org/packages/adminetic/notify)[![Stars](https://img.shields.io/github/stars/pratiksh404/adminetic-notify)](https://github.com/pratiksh404/adminetic-notify/stargazers) [![Downloads](https://img.shields.io/packagist/dt/adminetic/notify.svg?style=flat-square)](https://packagist.org/packages/adminetic/notify) [![StyleCI](https://github.styleci.io/repos/618407321/shield?branch=main)](https://github.styleci.io/repos/618407321?branch=main) [![License](https://img.shields.io/github/license/pratiksh404/adminetic-notify)](https://pratikdai404.gitbook.io/adminetic/addons/packagist.org/packages/adminetic/notify)

Notification module for Adminetic Admin Panel

**Contains: -**

* Notification Setting Panel
* My Notification Panel
* Notification Bell

## Installation

### **Step 1: Composer Install**

You can install the package via composer:

```bash
composer require adminetic/notify
```

### **Step 2: Database Notification**

Publish database notification migration

```bash
php artisan notification:table
```

### **Step 3: Migrate**

Migrate notification table.

```bash
php artisan migrate
```

### Step 4: Config&#x20;

Publish config file

```
php artisan vendor:publish --tag=notify-config
```

### Step 5: Notification Bell

Place notification bell component to views/admin/layouts/components/header

```html
<div class="nav-right col-8 pull-right right-header p-0">
@livewire('notify.notification-bell')
{{-- Other Codes --}}
 </div>
```

#### Include Adminetic Notification Adapter

In config/adminetic.php, include

```
    // Adapters
    'adapters' => [
        Adminetic\Notify\Adapter\NotifyAdapter::class,
    ],
```

## Configuration File

> ```php
> <?php
>
> return [
>
>     /*
>     |--------------------------------------------------------------------------
>     | Notification Configuration
>     |--------------------------------------------------------------------------
>     */
>     'available_notification_medium_in_system' => ['database', 'mail'],
>
>     /*
>     | OPTIONS:
>     | 'database','mail'
>     */
>     'general_notification_mediums' => ['database', 'mail'],
>
>     /*
>     |--------------------------------------------------------------------------
>     | Default Admin Notification By Role
>     |--------------------------------------------------------------------------
>     */
>     'admin_notification_by_role' => ['superadmin', 'admin'],
>
>     /*
>     |--------------------------------------------------------------------------
>     | Polling Configuration
>     |--------------------------------------------------------------------------
>     | Note pusher will be turned off if polling is turned on
>     */
>     'polling' => true,
>     'polling_intervals' => 10000
> ];
>
> ```

#### Note: Pusher will be turned of if polling is turned on

## Usage

### Default Setting Notification using : generalNotify()

```php
generalNotify([
  'title' => 'Hello',
  'message' => 'Default Notification'
])

```

This notification will go to all admin users by default, if you want custom user notification you can pass the user collection

```php
$users = User::latest()->take(3)->get();
generalNotify([
  'title' => 'Hello',
  'message' => 'Default Notification'
],$users)
```

Setting configuration for general notification is generated at `notification setting`

<figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2Fl7DkVpua5OzfLN0Ld2gx%2Fgeneral.jpg?alt=media&amp;token=42593465-2dd0-44d9-b3c6-6038a1c6d820" alt=""><figcaption></figcaption></figure>

### Custom Notification using : notify()

#### Steps :

* Create a notification setting with its name and group
* Configure its default value
* Extract its name to be used on notify() helper function for example if you named the notification setting as "New User Notification" use notify('new\_user\_notification')

```php
notify('new_user_notification',[
  'title' => 'Hello',
  'message' => 'Default Notification'
])
```

### Default Setting Override

Required field **`title`** and **`message`**

Overridable properties are:-

* title
* message
* subject
* action
* color
* type
* severity
* icon
* channels
* audience
* allow\_dismiss
* newest\_on\_top
* mouse\_over
* showProgressBar
* spacing
* timer
* placement\_form
* placement\_align
* delay
* animate\_enter
* animate\_exit

#### Usages

```php
notify('new_user_notification',[
  'title' => 'Hello',
  'message' => 'Default Notification',
  'subject' => 'About Default Notification',
  'action' => GeneralNotification::BROWSE, // BROWSE, READ, EDIT, ADD, DELETE if not don't pass action
  'color' => 'primary', // primary, secondary, warning, info, danger
  'type' => GeneralNotification::BROWSE, // INFO, ALERT, REMINDER, MESSAGE, NEWS REPORT
  'severity' => GeneralNotification::MID, // INSIGNIFICANT, READ, EDIT, ADD DELETE
  'icon' => 'fa fa-bell' // Any fontawesome icon
  'channels' => ['database','mail'],
  'audience' => [1,2,3], // User IDs
  'allow_dismiss' => true // Close Button
  'newest_on_top' => true,
  'mouse_over' => true, // Mouse over close disable
  'showProgressBar' => true,
  'spacing' => 5,
  'timer' => 1000 // In millisecond
  'placement_from' => 'bottom', // Vertical Alignment
  'animate_enter' => 'bounceIn',
  'animate_exit' => 'rubberBand'
])
```

### Screenshots

<div><figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2Fw3XwY7DHzyKTjVkrpT0s%2Fmy_notification.jpg?alt=media&amp;token=9e93b72a-f985-4329-8e60-37b44faf7751" alt=""><figcaption></figcaption></figure> <figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2F4j5rcGVBNblkVJTD7zmo%2Fnotification_bell.jpg?alt=media&amp;token=82b138cf-41a1-4fea-8b25-53260f7e640c" alt=""><figcaption></figcaption></figure> <figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2FpamhphpOKiMuZ7RaaXH0%2Fnotification_setting.jpg?alt=media&amp;token=c284bf3f-6074-463f-a5be-45cefbda3b97" alt=""><figcaption></figcaption></figure> <figure><img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbCZnEbkx6hMOJRn5tS%2Fuploads%2FWoPIgS6rRFuCQ9HBHtzR%2Fpopup.jpg?alt=media&amp;token=ac544cc9-6e32-48b6-8bf3-c53ab37c5cfa" alt=""><figcaption></figcaption></figure></div>

![Notification Setting](https://github.com/pratiksh404/adminetic-notify/blob/main/screenshots/notification_setting.jpg) ![My Notification](https://github.com/pratiksh404/adminetic-notify/blob/main/screenshots/my_notification.jpg) ![Notification Bell](https://github.com/pratiksh404/adminetic-notify/blob/main/screenshots/notification_bell.jpg)
