Laravel fenos/Notifynder扩展包使用

安装地址:https://github.com/fenos/Notifynder

具体安装:

"fenos/notifynder": "^4.0"
composer update     或者   composer require fenos/notifynder

Providers array:

Fenos\Notifynder\NotifynderServiceProvider::class,

Aliases array:

'Notifynder' => Fenos\Notifynder\Facades\Notifynder::class,
php artisan vendor:publish --provider="Fenos\Notifynder\NotifynderServiceProvider"
php artisan migrate

OK 到此安装完毕

接下来我们使用它

1.你需要创建模板

这里我们运用文档上的例子,创建一个类叫sayhello,然后模板hello good。。。。

php artisan notifynder:create:category "sayhello" "hello good {extra.period_day}"

2.接下来你就可以发送信息

use Notifynder;
$user_sender_id   = 1; // User sender
$user_receiver_id = 2; // User that receive the notification
$period_day = (is_morning()) ? 'morning' : 'evening';
$notifynder->category('sayhello')
           ->from(1)
           ->to(2)
           ->url('http://localhost')
           ->extra(compact('period_day'))
           ->send();

到此信息发送完毕

OK 接下来我们在客户端查看

use Fenos\Notifynder\Models\Notification;
use Notifynder;
....


public function myNews(Request $request){
        //dd($this->user);
        $message = $this->user->getNotifications(15,1,'desc');
        return view('home.my_news',compact('message'));
}

public function newsDetail(Request $request){
        $id = $request->get('id',0);
        $query = Notification::where('id',$id);
        if($id){
            $query->update(['read'=>2]);
            return response()->json(['success'=>1]);
        }
        $news_detail = $query->findOrFail($id);
        return view('home.news_detail',compact('news_detail'));

}



最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,286评论 19 139
  • 中文翻译 ng help ng build 构建您的应用程序并将其放入输出路径(dist /默认情况下)。 别名:...
    4ea0af17fd67阅读 2,075评论 0 0
  • 先说几句废话,调和气氛。事情的起由来自客户需求频繁变更,伟大的师傅决定横刀立马的改革使用新的框架(created ...
    wsdadan阅读 3,126评论 0 12
  • *面试心声:其实这些题本人都没怎么背,但是在上海 两周半 面了大约10家 收到差不多3个offer,总结起来就是把...
    Dove_iOS阅读 27,281评论 30 472
  • 原文链接:http://www.dropwizard.io/1.2.0/docs/getting-started....
    Lance_Xu阅读 993评论 0 0