사용 후 배열 밀어 내 쿼리 내가 원하는 나에게 적절한 결과를 제공PHP : Laravel - 여기 웅변 뽑은 방법
$RecipientList = Employees::select(DB::Raw('CONCAT(first_name," ",last_name) as employee_name'),'email')->pluck('employee_name','email');
,
입니다하지만 난 쿼리를 실행 한 후 나는 하나 이상의 키를 = > 값 쌍을 사용하여 결과 배열을 푸시합니다.
현재 결과를 인쇄하는 경우 다음과 같습니다.
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[[email protected]*****.com] => Punit Gajjar
[[email protected]*****.com] => Milan Gajjar
[[email protected]*****.com] => Pritesh Modi
[[email protected]*****.com] => Pratik Modi
[[email protected]*****.com] => Jyotiranjan J..
)
)
비트 만약 내가 키가 => valye 쌍이 작동하지 않습니다이 배열에 밀어보십시오.
array_push(array("All"=>"All"),$RecipientList);
당신은 Illuminate\Support\Collection
객체가 아닌 배열을
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[All] => All
[[email protected]*****.com] => Milan Gajjar
[[email protected]*****.com] => Milan Gajjar
[[email protected]*****.com] => Pritesh Modi
[[email protected]*****.com] => Pratik Modi
[[email protected]*****.com] => Jyotiranjan J..
)
)
아니 .. 내 결과가'이다를 분명히 \ 지원 \ 컬렉션 개체 ( [항목 : 보호] => 배열 ( [[email protected]*****.com] => 대한 Punit Gajjar [밀라노 @ * ****. com] => Milan Gajjar [[email protected]*****.com] => Pritesh Modi [[email protected]*****.com] => Pratik Modi [jyoti @ ***] **. com] => Jyotiranjan J .. [0] => 배열 ( [전체] => 모든 ) ) )'솔루션 사용 후. –
@PunitGajjar'prepend' 메소드는 어떻습니까? '$ RecipientList-> prepend ('All', 'All'); ' – aleksejjj
완벽한 .... !!!!!!!!!! –