theunreal's avatar

Laravel adding pet abbility information

Every user can have multiple pets. User and Pets are Many to Many relationship.

My pets have abbilities. My query retrived the abbility ID's, but I need the full abbility information along with the ID (like abbility name and description).

User Model method to get the user pets:

public function pets()
        {
            return $this->belongsToMany(Pet::Class, 'user_pets')->withPivot(
            'abbility1_id',
            'abbility2_id',
            'abbility3_id',
            'abbility4_id'
            )->orderBy('position','asc');
        }

my api output is: http://i.stack.imgur.com/KkyiO.png

Desired output: I need the information of each attack_id for each pet

0 likes
1 reply
hupp's avatar

@theunreal Could you please post the query code you are using in controller or other page, that will give better idea to check things

Please or to participate in this conversation.