php - Extracting a pivot field one level up in laravel

one text

Solution:

in think you can make addSelect inside your eager loading ....

   $value = Community::where('id', 1)->with(['personas'=> function ($query) {
            $query->join('communities_personas', 'personas.id', 'communities_personas.personas_id')->
            addSelect(['communities_personas.member_count,communities_personas.personas_id']);
        }])->get();

i'm not sure about your tables and models name, please correct the wrong ones ...

and make sure you also addselect the foreign key between the personas table and the pivot table.

Source