Laravel fenos/Notifynder擴(kuò)展包使用

安裝地址: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 到此安裝完畢

接下來(lái)我們使用它

1.你需要?jiǎng)?chuàng)建模板

這里我們運(yùn)用文檔上的例子,創(chuàng)建一個(gè)類叫sayhello,然后模板hello good。。。。

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

2.接下來(lái)你就可以發(fā)送信息

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();

到此信息發(fā)送完畢

OK 接下來(lái)我們?cè)诳蛻舳瞬榭?/p>

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'));

}



最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,654評(píng)論 19 139
  • 中文翻譯 ng help ng build 構(gòu)建您的應(yīng)用程序并將其放入輸出路徑(dist /默認(rèn)情況下)。 別名:...
    4ea0af17fd67閱讀 2,141評(píng)論 0 0
  • 先說(shuō)幾句廢話,調(diào)和氣氛。事情的起由來(lái)自客戶需求頻繁變更,偉大的師傅決定橫刀立馬的改革使用新的框架(created ...
    wsdadan閱讀 3,198評(píng)論 0 12
  • *面試心聲:其實(shí)這些題本人都沒(méi)怎么背,但是在上海 兩周半 面了大約10家 收到差不多3個(gè)offer,總結(jié)起來(lái)就是把...
    Dove_iOS閱讀 27,628評(píng)論 30 472
  • 原文鏈接:http://www.dropwizard.io/1.2.0/docs/getting-started....
    Lance_Xu閱讀 1,161評(píng)論 0 0

友情鏈接更多精彩內(nèi)容