承接 wpzag/laravel-notifications 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wpzag/laravel-notifications

最新稳定版本:v1.0.4

Composer 安装命令:

composer require wpzag/laravel-notifications

包简介

This is my package laravel-notifications

README 文档

README

Installation

You can install the package via composer:

composer require wpzag/laravel-notifications

Create notifications table

php artisan notifications:table
php artisan migrate

Usage

  1. First we need to use the Notifiable trait in the user model:
    use Wpzag\LaravelNotifications\Traits\Notifiable;
    class User extends Authenticatable
    {
        use Notifiable;
     }
  1. Then we need to create a notification class that extends BaseNotification class:
 <?php
	
	namespace App\Notifications;
	
	use Wpzag\LaravelNotifications\BaseNotification;
	
	class TestNotification extends BaseNotification
	{
		public function getTranslationParams() : array
		{
			return [
				'user'=>'user.name',
			];
		}
		
		
		public function getNotificationLink() : string
		{
			return 'users/'.$this->relations['user']['id'];
		}
	}
  1. Create notifications.php in lang/en and add entry in translation file:
return [
  'user_updated' => ':user has updated his profile',
  'titles' => [ 'user_updated' => 'User Updated' ],
]
  1. Notify the user
   User::first()->notify(
         TestNotification::create(
                 key: 'user_updated',
                 relations: ['user' => User::first()],
                 data: ['random' => 'data']
    ));
  1. Then we get the notifications with:
  use Wpzag\LaravelNotifications\LaravelNotifications;
  LaravelNotifications::getPaginatedNotifications();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-14