Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging #16

Closed
eduardonwa opened this issue Mar 3, 2021 · 1 comment
Closed

Debugging #16

eduardonwa opened this issue Mar 3, 2021 · 1 comment

Comments

@eduardonwa
Copy link

eduardonwa commented Mar 3, 2021

In the "Build a Like/Dislike system" episode 67 of the series, in 22:23 timestamp, we start including the "like" and "dislike" buttons and im getting a Call to a member function where() on null this happens after I implement this on the _tweet.blade.php blade file

<div class="flex items-center {{ $tweet->isDislikedBy( current_user() ) ? 'text-blue-500' : 'text-gray-500' }}">

The error is actually being returned in line 4:

1.    public function isDislikedBy(User $user)
2.    {
3.        return (bool) $user->likes
4.            ->where('tweet_id', $this->id) 
5.            ->where('liked', false)
6.            ->count();
7.    }

How can I start knowing what's going on in or out from the isDislikedBy() ? What im thinking is that I should be back-engineering the source of that where function because what's inside of it, it's returning null. I noticed jeffrey doesn't ever references a Model, like for example, this: use App\Like and that happens in most of the files, where as I have had to do that in some Models. I know he's on Laravel 6 and Im wondering if in Laravel 8, the reason why it's returning null is because an endpoint somewhere isn't being referenced. Thanks! Awesome project.

@eduardonwa
Copy link
Author

I checked the repo, turns out I somehow forgot to keep likes() in User

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant