I have a relationship in my model that requires a were condition:
public function characters() { return $this->hasMany('Character')->where('characters.game_id', $this->game_id); }
The problem is that "$this->game_id" doesn't appear to work. If I hard code the ID I need in its place, then the relationship works fine. I've also tried "$this->attributes['game_id']", which doesn't work either. I know that the value for "$this->game_id" exists, because I can view it when I return it in an accessor or as just a normal property in the resulting object. But for whatever reason, I can't access this value in the relationship. Thoughts?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/27xUEij
via IFTTT
Aucun commentaire:
Enregistrer un commentaire