安裝地址: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'));
}