Trying to get property 'likes' of non-object (View: /app/resources/views/products/productView.blade.php) on my local server this is working and on hosting it is giving error. I dont know where I am doing this wrong
Query
$findLikes = Comment::where('user_id', Auth::user()->id)->where('product_id', $id)->first();
View
@if((Auth::check()) && ($findLikes->likes == '1'))
<a href="/unlike-product/" id="myNumber" name="likes" value="0" onclick="myFunction()"><i class="fa fa-heart-o"></i> UnLike</a> </small>
@elseif((Auth::check()) && ($findLikes->likes == '0'))
<a href="/liked-product/" id="myNumber" name="likes" value="1" onclick="myFunction()"><i class="fa fa-heart-o"></i> Like it</a> </small>
@endif
THIS IS I WHAT TRIED NOW AND NOT RETURNING ANYTHING BUT LOADING THE PAGE
@if((Auth::check()) && $findLikes)
@if($findLikes->likes == '1')
<a href="/unlike-product/" id="myNumber" name="likes" value="0" onclick="myFunction()"><i class="fa fa-heart-o"></i> UnLike</a> </small>
@else
<a href="/liked-product/" id="myNumber" name="likes" value="1" onclick="myFunction()"><i class="fa fa-heart-o"></i> Like it</a> </small>
@endif
@endif
UPDATED
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2WVNiHB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire