خرید بک لینک

Vote count: 0

I have four tables: characters, pets, characters_pets and characters_pets_metadata. A character has many pets on the pivot table characters_pets, but I also need to get the data from the metadata table:

class Character extends Model {

    protected $table = 'characters';

    public function pets() {
        retu $this->belongsToMany('Pet', 'characters_pets');
    }
}



class CharacterPet extends Model {

    protected $table = 'characters_pets';

    public function metadata() {
        retu $this->hasMany('PetMetadata');
    }

}

How can I fetch the metadata for each character through a relationship?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 2 مرداد 1395 ساعت: 17:30

صفحه بندی