fgh151 / yii2-noifications
Yii2 notifications module
Installs: 85
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-28 23:03:17 UTC
README
Yii2 notifications module
This module provide functions to send notifications to user. Implements admin part where you can wie messages and create item. In frontend messages will be in bootstrap alert box, By the timer widget ask backend for new messages and show them.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist fgh151/yii2-noifications "*"
or add
"fgh151/yii2-noifications": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code to config :
'modules' => [ ... 'notification' => [ 'class' => 'fgh151\notifications\Module' ] ]
then include widget on pages where module will be:
echo fgh151\notifications\widgets\notifications\Widget::widget();
API
You can direct create message, for example:
$notify = new fgh151\notifications\models\Notification(); $notify->Message = $message; $notify->UserId = $user; $notify->Type = $type; $notify->save();
or you can use method send:
fgh151\notifications\models\Notification::send('info', 'Info message' , 127);
where first argument - type of bootstrap message, second - message text, third - receiver user id, also you can send array of users, for example:
fgh151\notifications\models\Notification::send('info', 'Info message' , [1,2,3,4,5]);