mardi 24 avril 2018

How to Show an element onclick onclick only if the user is logged in if not redirects to login using Laravel

I want to be able to show an element (phone number) which is initially hidden. I have a button called show phone which on click will display the element containing the phone number which was hidden. It is working quite alright but I want to add a new rule for it to show the phone number. I want it to show the phone number only if the user is logged in to his account if it will redirect to the login page with a flash message saying "In order to view this phone number you must be logged in". I tried to put an auth::check to the div and got stuck at this point. Can anyone please tell me how can I achieve that using Laravel.

Here is my view

<span class="job-is ft"  id="more" onclick="$('.details').slideToggle(function(){$('#more').html($('.details').is(':visible')?'Hide Phone':'Show Phone');});">Voir le numero</span>
 @if (Auth::check()) 
<div class="extra-job-info details" style="display:none">
                                        <p style="text-align: center; padding: 10px; font-size: 45px;"><i class="la la-phone"></i> </p>
                                    </div>  
  @endif 

Do anyone know an easy way to achieve this? Any help will be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire