lundi 24 mai 2021

Laravel Side Bar Menus are Hidden when notification is sent or when modal pop-up

I have this problem with my website project when notification is sent or when a modal pop-up my sidebar menus are gone, and also the logo. Here is the screenshot to be more understandable.enter image description here...I used pusher to send a real-time notification but when it sends the notification the above will occur and need to refresh the page so that the menus and logo can be seen again. Here I used laravel controller to trigger the pusher event here is my code on it.

`class PublicController extends Controller
{
    public function notify(){

        $token = Session::get('utoken');
        User::where('token', $token)->update(['notify' => 1]);
        \Helper::calculateResult($token);
        User::where('token', $token)->update(['status' => 'finish']);
        $notify = DB::table('users')->where('notify', 1)->select('name','id')->get();
        $notify=$notify->toArray();
        event(new ExamSubmitted($notify));
        return view('finish');
    }
    
}`

and in my blade i have this script in the head tag

    <script>

    Pusher.logToConsole = true;
    
    var pusher = new Pusher('pusher_key', {
      cluster: 'ap1'
    });

    var channel = pusher.subscribe('exam-channel');
    channel.bind('exam-event', function(data) {
        $("span").remove();
        $(".notif").empty();
      if(data['notify'].length>0){
        
        $("#notify").append("<span class='badge custom-badge'>"+data['notify'].length+"</span>");
        data['notify'].forEach(function(value){
          $(".notif").append(
            "<li> <a id='app_modal' data-id ="+value['id']+" href='javascript:void(0)'>"
                  +"<div class='row'>"
                   +" <div class='col-sm-2'><img src=\"\"class='img-size-50 img-circle'></div>"
                   +"<div class='col-sm-8' style='line-height: .5;'>"
                      +"<p style='font-size: 1.6rem'>"+value['name']+"</p>"
                      +"<p style='font-size: 1.2rem'>Just Completed the exam.</p>"
                      +"<p class='text-sm text-muted'><i class='fa fa-clock mr-1'></i> 4 Hours Ago</p>"
                    +"</div>"+
                    "<div class='col-sm-2 text-success'><i class='fa fa-star fa-lg'></i></div>"
                +"</div></div></a>"+
            "</li><div class='dropdown-divider'>"
            );
        });
        
      }
    });
  </script>

Did I do something wrong?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3fHDUiP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire