GlobalComposer.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Http\ViewComposers;
  3. use Illuminate\Contracts\View\View;
  4. use Illuminate\Support\Facades\Auth;
  5. use Menu;
  6. use App\Models\Notification;
  7. use App\Models\Ticket;
  8. use App\Models\CompanyModel;
  9. class GlobalComposer {
  10. /**
  11. * Bind data to the view.
  12. *
  13. * @param View $view
  14. * @return void
  15. */
  16. public function compose(View $view)
  17. {
  18. if(Auth::check())
  19. {
  20. $user_id = \Auth::user()->id;
  21. }
  22. else{
  23. $user_id = 0;
  24. }
  25. $noti = Notification::where('user_id',$user_id)->where('status',1)
  26. ->orderBy('id','DESC')->get();
  27. $total_noti = count($noti);
  28. $view->with('total_noti', $total_noti);
  29. if($total_noti > 0){
  30. $view->with('noti', $noti);
  31. }
  32. else{
  33. $noti = Notification::where('user_id',$user_id)
  34. ->orderBy('id','DESC')->take(10)->get();
  35. $view->with('noti', $noti);
  36. }
  37. if(Auth::user()){
  38. if(Auth::user()->utype==1){
  39. $support_noti= Ticket::where('status','<',3)->orderBy('id','DESC')->get();
  40. $total_support_noti=count($support_noti);
  41. $view->with('total_support_noti', $total_support_noti);
  42. if($total_support_noti > 0){
  43. $view->with('support_noti', $support_noti);
  44. } else{
  45. $support_noti= Ticket::where('status','<',3)->orderBy('id','DESC')->take(10)->get();
  46. $view->with('support_noti', $support_noti);
  47. }
  48. }
  49. }
  50. }
  51. }