surendramannam1's avatar

I need to show pop up only first time user login

 
  </div>
  <div class="modal-body">
    <h2>Welcome to Dr.Drop!</h2>
      <p>Dr.Drop is a community-driven ecommerce website<br>

we provide members with a place where they can order supplies, Join drops, and connect with other members all in one place.

Get Started

  </div>
</div>
$(window).load(function(){ $('#myModal').modal('show'); });
0 likes
7 replies
alielkhateeb's avatar

Three steps:

  • Create a flag in the users table (defaults to false)
  • After a user logs in, if his flag is false show the pop up
  • Flip the logged in user flag to true in the users table
1 like
surendramannam1's avatar

Create a flag in the users table (defaults to false) first step completed

but i am not getting exact steps regarding second and third one steps

if you have any sample code please provide that is very helpful

thanks a lot Mr.alielkhateeb

alielkhateeb's avatar
Level 1

@surendramannam1 Ok no problem.

If you installed Laravel from scratch, I suggest you follow this Doc, this will create all the login views and register views and handle all your session authentication

So since you finished your first part (creating a flag in the users table) then all you need to do in your home page controller something like this:

// Hint: Auth::user() is the currently signed in user object.
$first_time_login = false;
if (Auth::user()->first_time_login) {
    $first_time_login = true;
    Auth::user()->first_time_login = 1; // Flip the flag to true
    Auth::user()->save(); // By that you tell it to save the new flag value into the users table
}

// Now send the variable $first_time_login to your view
return view('pages.yourviewname', ['first_time_login' => $first_time_login]);

And in yourviewname.blade.php template, based on the value of $first_time_login you can show/hide a certain div, for example:

@if ($first_time_login)
    <div>This div will show on your first time to log in only</div>
@endif 

Please don't hesitate to ask again if you are still struggling, that's basically why Laracasts exists :D, and btw accept the answers that really answers your question, I asked you to do it only if it answered your question, thanks man and happy coding.

3 likes

Please or to participate in this conversation.