У меня есть модель Mailgroup с отношением для получения CommunicationType, вот так:
$communicationTypes = $mailgroup->communicationTypes->toArray();
Возвращает:
array (size=3)
0 =>
array (size=3)
'id' => int 9
'mailgroup_id' => int 16
'communication_type' => string 'a' (length=1)
1 =>
array (size=3)
'id' => int 10
'mailgroup_id' => int 16
'communication_type' => string 'b' (length=1)
2 =>
array (size=3)
'id' => int 11
'mailgroup_id' => int 16
'communication_type' => string 'c' (length=1)
Моя цель - получить это:
array (size=3)
0 => string 'a' (length=1)
1 => string 'b' (length=1)
2 => string 'c' (length=1)
Теперь я попробовал следующее, но все приводит к ошибке.
$communicationTypes = $mailgroup->communicationTypes()->communication_type->toArray();
$communicationTypes = $mailgroup->communicationTypes()->pluck('communication_type')->toArray();