jeudi 3 août 2017

Not able to access the variable equivalent of the eloquent method

I have the following eloquent method in my application:

public function votes() {
        return $this->morphMany(Vote::class, 'votable');
    }

and when I try to access the variable votes (as laravel has dynamic properties) like $userVote = $this->votes->where('user_id', $user->id)->first();, I get the following error: "Call to a member function where() on integer" and when I use dd($this->votes) it displays 2. I am all confused.

Where am I going wrong?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2u6iAu1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire