123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Http\ViewComposers;
- use Illuminate\Contracts\View\View;
- use Illuminate\Support\Facades\Auth;
- use Menu;
- use App\Models\Notification;
- use App\Models\Ticket;
- use App\Models\CompanyModel;
- class GlobalComposer {
- /**
- * Bind data to the view.
- *
- * @param View $view
- * @return void
- */
- public function compose(View $view)
- {
- if(Auth::check())
- {
- $user_id = \Auth::user()->id;
- }
- else{
- $user_id = 0;
- }
-
- $noti = Notification::where('user_id',$user_id)->where('status',1)
- ->orderBy('id','DESC')->get();
- $total_noti = count($noti);
- $view->with('total_noti', $total_noti);
- if($total_noti > 0){
- $view->with('noti', $noti);
- }
- else{
- $noti = Notification::where('user_id',$user_id)
- ->orderBy('id','DESC')->take(10)->get();
- $view->with('noti', $noti);
- }
- if(Auth::user()){
- if(Auth::user()->utype==1){
- $support_noti= Ticket::where('status','<',3)->orderBy('id','DESC')->get();
- $total_support_noti=count($support_noti);
- $view->with('total_support_noti', $total_support_noti);
- if($total_support_noti > 0){
- $view->with('support_noti', $support_noti);
- } else{
- $support_noti= Ticket::where('status','<',3)->orderBy('id','DESC')->take(10)->get();
- $view->with('support_noti', $support_noti);
- }
- }
-
- }
-
-
- }
- }
|