If statement not presenting the else resultmysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or resultClient Credit Management with IF and ELSE statementIn Laravel, the best way to pass different types of flash messages in the sessionCSRF (Cross Site Request Forgery) does not work as expected in LaravelLaravel 5.3 Form post error session store not set on requestLaravel - Display form results on the same page after mutliple forms submitWhy is my validation on my Laravel form failing and routing to a different page?Put if conditions in route laravelDynamic form not sending all valuesHow to insert/post data in laravel using ajax into Database by query builder method without using model

Draw the ☣ (Biohazard Symbol)

Professor refuses to write a recommendation letter to students who haven't written a research paper with him

Why did Boris Johnson call for new elections?

Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?

Does POSIX guarantee the paths to any standard utilities?

Is the Levitate spell supposed to basically disable a melee-based enemy?

How does the UK House of Commons think they can prolong the deadline of Brexit?

What fraction of 2x2 USA call signs are vanity calls?

Undefined Hamiltonian for this particular Lagrangian

Is there any reason to change the ISO manually?

Fantasy Military Arms and Armor: the Dwarven Grand Armory

French equivalent of "my cup of tea"

What quests do you need to stop at before you make an enemy of a faction for each faction?

What's the eccentricity of an orbit (trajectory) falling straight down towards the center?

Regex pattern matching cursor-position

RAW, Is the "Finesse" trait incompatible with unarmed attacks?

Was "The Hobbit" ever abridged?

Why there are construction cranes on apparently completed buildings in New York?

Is a paralyzed creature limp or rigid?

Do I have to rename all creatures in a new world?

If I sell my PS4 game disc and buy a digital version, can I still access my saved game?

Bidirectional Dictionary

How can I oppose my advisor granting gift authorship to a collaborator?

Dissuading my girlfriend from a scam



If statement not presenting the else result


mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or resultClient Credit Management with IF and ELSE statementIn Laravel, the best way to pass different types of flash messages in the sessionCSRF (Cross Site Request Forgery) does not work as expected in LaravelLaravel 5.3 Form post error session store not set on requestLaravel - Display form results on the same page after mutliple forms submitWhy is my validation on my Laravel form failing and routing to a different page?Put if conditions in route laravelDynamic form not sending all valuesHow to insert/post data in laravel using ajax into Database by query builder method without using model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















The else section of my code is not being displayed in my laravel blade. I need to get the else section of the statement to show. currently, that button is missing when the if statement is false.



@auth
@if(optional($quote->userLike))
@foreach($quote->userLike as $like)
@if($like->pivot->user_id == $id) //passing user id from controller here
<li class="list-inline-item">
<form method="POST" action="route('likequote')" class="likequote">
@csrf
<input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
<button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
</form>
</li>
@endif
@endforeach
@else
<li class="list-inline-item">
<form method="POST" action="route('likequote')" class="likequote">
@csrf
<input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
<button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
</form>
</li>
@endif
@endauth










share|improve this question
































    1















    The else section of my code is not being displayed in my laravel blade. I need to get the else section of the statement to show. currently, that button is missing when the if statement is false.



    @auth
    @if(optional($quote->userLike))
    @foreach($quote->userLike as $like)
    @if($like->pivot->user_id == $id) //passing user id from controller here
    <li class="list-inline-item">
    <form method="POST" action="route('likequote')" class="likequote">
    @csrf
    <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
    <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
    </form>
    </li>
    @endif
    @endforeach
    @else
    <li class="list-inline-item">
    <form method="POST" action="route('likequote')" class="likequote">
    @csrf
    <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
    <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
    </form>
    </li>
    @endif
    @endauth










    share|improve this question




























      1












      1








      1








      The else section of my code is not being displayed in my laravel blade. I need to get the else section of the statement to show. currently, that button is missing when the if statement is false.



      @auth
      @if(optional($quote->userLike))
      @foreach($quote->userLike as $like)
      @if($like->pivot->user_id == $id) //passing user id from controller here
      <li class="list-inline-item">
      <form method="POST" action="route('likequote')" class="likequote">
      @csrf
      <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
      <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
      </form>
      </li>
      @endif
      @endforeach
      @else
      <li class="list-inline-item">
      <form method="POST" action="route('likequote')" class="likequote">
      @csrf
      <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
      <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
      </form>
      </li>
      @endif
      @endauth










      share|improve this question
















      The else section of my code is not being displayed in my laravel blade. I need to get the else section of the statement to show. currently, that button is missing when the if statement is false.



      @auth
      @if(optional($quote->userLike))
      @foreach($quote->userLike as $like)
      @if($like->pivot->user_id == $id) //passing user id from controller here
      <li class="list-inline-item">
      <form method="POST" action="route('likequote')" class="likequote">
      @csrf
      <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
      <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
      </form>
      </li>
      @endif
      @endforeach
      @else
      <li class="list-inline-item">
      <form method="POST" action="route('likequote')" class="likequote">
      @csrf
      <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
      <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
      </form>
      </li>
      @endif
      @endauth







      php laravel laravel-5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 6:03









      Akash Kumar Verma

      1,2842 gold badges5 silver badges17 bronze badges




      1,2842 gold badges5 silver badges17 bronze badges










      asked Mar 28 at 4:22









      Davinchi1Davinchi1

      105 bronze badges




      105 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          0
















          • first method

          @auth
          @forelse($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @empty
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endforelse
          @endauth


          • Second

          @auth
          @if(!empty($quote->userLike) && count($quote->userLike)>0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endauth





          share|improve this answer



























          • Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

            – Davinchi1
            Mar 28 at 12:48











          • that's my mistake i updated answer. please mark this as accepted answer

            – Akash Kumar Verma
            Mar 28 at 12:58











          • also updated second solution

            – Akash Kumar Verma
            Mar 28 at 13:19


















          0
















           You can try this 

          @auth
          @isset($quote)
          @if($quote->userLike->count() > 0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endisset
          @endauth





          share|improve this answer

























          • Thanks @manisha. This works, even without the @isset

            – Davinchi1
            Mar 28 at 12:51













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390132%2fif-statement-not-presenting-the-else-result%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          • first method

          @auth
          @forelse($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @empty
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endforelse
          @endauth


          • Second

          @auth
          @if(!empty($quote->userLike) && count($quote->userLike)>0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endauth





          share|improve this answer



























          • Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

            – Davinchi1
            Mar 28 at 12:48











          • that's my mistake i updated answer. please mark this as accepted answer

            – Akash Kumar Verma
            Mar 28 at 12:58











          • also updated second solution

            – Akash Kumar Verma
            Mar 28 at 13:19















          0
















          • first method

          @auth
          @forelse($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @empty
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endforelse
          @endauth


          • Second

          @auth
          @if(!empty($quote->userLike) && count($quote->userLike)>0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endauth





          share|improve this answer



























          • Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

            – Davinchi1
            Mar 28 at 12:48











          • that's my mistake i updated answer. please mark this as accepted answer

            – Akash Kumar Verma
            Mar 28 at 12:58











          • also updated second solution

            – Akash Kumar Verma
            Mar 28 at 13:19













          0














          0










          0









          • first method

          @auth
          @forelse($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @empty
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endforelse
          @endauth


          • Second

          @auth
          @if(!empty($quote->userLike) && count($quote->userLike)>0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endauth





          share|improve this answer















          • first method

          @auth
          @forelse($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @empty
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endforelse
          @endauth


          • Second

          @auth
          @if(!empty($quote->userLike) && count($quote->userLike)>0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endauth






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 13:19

























          answered Mar 28 at 4:27









          Akash Kumar VermaAkash Kumar Verma

          1,2842 gold badges5 silver badges17 bronze badges




          1,2842 gold badges5 silver badges17 bronze badges















          • Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

            – Davinchi1
            Mar 28 at 12:48











          • that's my mistake i updated answer. please mark this as accepted answer

            – Akash Kumar Verma
            Mar 28 at 12:58











          • also updated second solution

            – Akash Kumar Verma
            Mar 28 at 13:19

















          • Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

            – Davinchi1
            Mar 28 at 12:48











          • that's my mistake i updated answer. please mark this as accepted answer

            – Akash Kumar Verma
            Mar 28 at 12:58











          • also updated second solution

            – Akash Kumar Verma
            Mar 28 at 13:19
















          Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

          – Davinchi1
          Mar 28 at 12:48





          Thanks @Akash The first example works if I remove the @endforeach in the middle. The second does not work. Button does not show.

          – Davinchi1
          Mar 28 at 12:48













          that's my mistake i updated answer. please mark this as accepted answer

          – Akash Kumar Verma
          Mar 28 at 12:58





          that's my mistake i updated answer. please mark this as accepted answer

          – Akash Kumar Verma
          Mar 28 at 12:58













          also updated second solution

          – Akash Kumar Verma
          Mar 28 at 13:19





          also updated second solution

          – Akash Kumar Verma
          Mar 28 at 13:19













          0
















           You can try this 

          @auth
          @isset($quote)
          @if($quote->userLike->count() > 0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endisset
          @endauth





          share|improve this answer

























          • Thanks @manisha. This works, even without the @isset

            – Davinchi1
            Mar 28 at 12:51















          0
















           You can try this 

          @auth
          @isset($quote)
          @if($quote->userLike->count() > 0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endisset
          @endauth





          share|improve this answer

























          • Thanks @manisha. This works, even without the @isset

            – Davinchi1
            Mar 28 at 12:51













          0














          0










          0









           You can try this 

          @auth
          @isset($quote)
          @if($quote->userLike->count() > 0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endisset
          @endauth





          share|improve this answer













           You can try this 

          @auth
          @isset($quote)
          @if($quote->userLike->count() > 0)
          @foreach($quote->userLike as $like)
          @if($like->pivot->user_id == $id) //passing user id from controller here
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endforeach
          @else
          <li class="list-inline-item">
          <form method="POST" action="route('likequote')" class="likequote">
          @csrf
          <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='$quote->id'>
          <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
          </form>
          </li>
          @endif
          @endisset
          @endauth






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 12:27









          ManishaManisha

          748 bronze badges




          748 bronze badges















          • Thanks @manisha. This works, even without the @isset

            – Davinchi1
            Mar 28 at 12:51

















          • Thanks @manisha. This works, even without the @isset

            – Davinchi1
            Mar 28 at 12:51
















          Thanks @manisha. This works, even without the @isset

          – Davinchi1
          Mar 28 at 12:51





          Thanks @manisha. This works, even without the @isset

          – Davinchi1
          Mar 28 at 12:51

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390132%2fif-statement-not-presenting-the-else-result%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript