Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel adding condition to relation

class Game extends Eloquent {
    // many more stuff here

    // relation without any constraints ...works fine 
    public function videos() {
        return $this->hasMany('Video');
    }

    // results in a "problem", se examples below
    public function available_videos() {
        return $this->videos()->where('available','=', 1)->get();
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #adding #condition #relation
ADD COMMENT
Topic
Name
2+4 =