laravel得到关系表为key => val

时间:2017-06-13 11:54:37

标签: php laravel eloquent

Fisrt抱歉我的英语不好。其次我有一个内容表与user,meta等关系..我的contents_meta表是这样的

---------------------------------
content_id |   option  |  value
---------------------------------
    1           price     12
---------------------------------
    2           price     14.1
---------------------------------

并像这样查询

$lists = Content::with([
    'categories',
    'user',
    'metas' => function($qm){
        $qm->get()->pluck('option','value');
    },
    'transactions' => function($q){
        $q->where('mode','deliver');
    }
])->withCount('sells','partsactive');

我使用pluck来更改content_meta表key => val

$item->metas->price = ???[get value]

但是没有工作,所有内容都在数组中返回。我如何转换为key => val会导致查询?

0 个答案:

没有答案