ApplicationNotificationComposer.php 485 B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Http\ViewComposers;
  3. use Auth;
  4. use Illuminate\Contracts\View\View;
  5. use Illuminate\Support\Facades\Notification;
  6. class ApplicationNotificationComposer{
  7. public function compose(View $view){
  8. $user = Auth::user();
  9. $notifications = $user->notifications->take(15);
  10. $unreadnotifications = $user->unreadnotifications;
  11. $view->with('notifications',$notifications);
  12. $view->with('unreadnotifications',$unreadnotifications);
  13. }
  14. }
  15. ?>