mercredi 29 août 2018

how to extend a view having dynamic data in laravel

From a controller method i send $notifications to the home view and display notifications on header of my website.

The Profile views extends the home view, and i also wanted to display the notifications on profile view.

But it generates an error that undefined variable $notifications when i request for profile view.

I think one solution is that to send $notifications when returning profile view from controller method, but in website there are many views on which i wanted to show notification tab so it's the right way that i am thinking.

here is the code in the home view in the header section

<ul class="dropdown-menu" id="notificationlist">
            @foreach($notifications as $notification)
        <li><a href="" class="dropdown-item">
                <img src="http://localhost/webproject/public/user_images/" class="img-thumbnil" width="20px" height="20px"> <strong></strong>
                <span style="white-space: initial;">sent you a friend request.</span>
                </a></li>
                @endforeach
                </ul>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire