1
그래서 모델 요청이 있습니다어떻게 Laravel 결과 쿼리에 새 필드를 추가하는
"id" => 32
"name" => "Rock"
"position" => null
"updated_at" => "2017-02-07 06:16:46"
"created_at" => "2017-02-07 06:16:46"
가 어떻게이 객체에 새로운 요소 list = []
을 추가 할 수 있습니다
$genres = Genre::all();
그것은 나 개체 reuslt 제공을?
'$ genres-> 목록 = [];' – EddyTheDove
내가 찾은 솔루션 여기 : https://laracasts.com/discuss/channels/laravel/how-to-add-a-new-element- to-every-item-of-collection? page = 1 – Darama
이 솔루션을 사용해보십시오 : [http://stackoverflow.com/questions/31474452/manually-add-item-to-existing-object-laravel-5] (http://stackoverflow.com/questions/31474452/manually-add-item-to-existing-object-laravel-5) –