0

Good afternoon !

I have a simple problem , I have this code that works correctly.

<a onclick='flotante(1)' data-auction="+data.subastas[i].id+" class='tester btn btn-default col-md-12'>Pujar</a>

This code return the id of subasta , then I am using Laravel and PHP , when the user is log and click on Auction , I need to call a jquery function.

I have the following code

@if(Auth::user()) AA @else Inicio de sesión

             <div class="row ">
                    <div class="col-md-6">
                        <label for="email">Email</label>
                    </div>
                    <div class="col-md-6">
                        <input type="email" name="email" class="form-control margeninput"/>
                    </div>
                </div>
                 <div class="row ">
                    <div class="col-md-6">
                    <label for="password">Password</label>
                    </div>
                    <div class="col-md-6">
                    <input type="password" name="password" class="form-control margeninput"/>
                    </div>
                </div>                  
                <div class="row ">
                <input type="submit" id="singlebutton" class=" col-md-6 col-md-offset-3 " name="singlebutton" style="margin-bottom:5px;"></input> 
                </div>
        </fieldset>
        <input type="hidden" name="_token" value="{{ csrf_token() }}"> 
    </form>
     @foreach ($errors->all() as $error)
    <div class="bderrors">
    <p class="span-error">{{ $error }}</p>
     </div>
     @endforeach

@endif

However I try to use this

@if(Auth::user())
    <script type="text/javascript">
        alert("OK");
    </script>
@else

This code works when the user is login but not when user has doing click in auction.

Could anyone help to me?

jc1992
  • 644
  • 3
  • 10
  • 24

1 Answers1

1

I recommend you to read this questions and answers

How to pass variables and data from PHP to JavaScript?

Maybe its more easy for you to do this (like and ajax function that just call and controller and do a function "isLogin").

Community
  • 1
  • 1
Itipacs
  • 182
  • 7
  • Ok for your answer I understan that I need to check if user isLogin , depence of the result I Can do one action or other action. – jc1992 Dec 30 '15 at 19:54