laravel-favorite
laravel-favorite copied to clipboard
How to check in view file if the user has liked the post?
I am trying to show the different colors for liked and non-liked users on the view file.
I am using laravel 7, how to use $post->isFavorited()
on laravel view file, with if-else
statement...
You can do it like this
<span class="{{ $post->isFavorited() ? 'bg-yellow-500' : 'bg-gray-500' }}">⭐</span>
but it gives me eager loading issue https://github.com/ChristianKuri/laravel-favorite/issues/32