2
내 Laravel 코드에서 코드의 어딘가에서 레코드를 처리 할 때 배열에 새 속성을 추가합니다 (예 : $ obj-> newAttr = someContent). 내가 객체를 dd() 할 때 #attributes와 #original이라는 두 개의 배열을 보여 주지만 새로 생성 된 속성은 #attributes 배열에만 나타난다.datt()에 대한 #attributes vs #original
#attributes: array:21 [▼
"field_name" => "229"
"company_name" => "Maya Dairy"
"seeding_rate" => 115
"id" => 11
"property_id" => 71
"acreage" => "73.80"
"status" => "current"
"dairy_crop_variety_id" => 19
"field_weight" => "1432.39"
"moisture" => "67.00"
"starch" => null
"yield_id" => 50
"crop" => "Wheat: <strong>Sumit 515</strong> @ <strong>21.3 T/c</strong>"
"variety" => "Sumit 515"
"planted_at" => "Nov 10, 2016"
"harvested_at" => "May 1, 2017"
"crop_age" => 172
"cropDateLink" => "Harvested: <a href="#" data-toggle="modal" data-target="#editRowCrop" data-id="11" data-method="PATCH"><strong>May 1, 2017</strong> (172 days)</a>"
"yield" => 21.3
"inputs" => ""
"files" => ""
원래 배열 :
#original: array:16 [▼
"field_name" => "229"
"company_name" => "Maya Dairy"
"seeding_rate" => 115
"id" => 11
"property_id" => 71
"acreage" => "73.80"
"status" => "current"
"dairy_crop_variety_id" => 19
"field_weight" => "1432.39"
"moisture" => "67.00"
"starch" => null
"yield_id" => 50
"crop" => "Wheat"
"variety" => "Sumit 515"
"planted_at" => "2016-11-10"
"harvested_at" => "2017-05-01"
이 배열의 차이는 무엇 I는() 객체를 위해 dd 때 여기
는 I가 #attributes 어레이를 얻는 예이다? 때로는 새로 생성 된 속성을보기에 사용할 수없는 경우가 있습니다. 왜 그런지 모르겠습니다. 모든 제안은 높이 평가됩니다.
원본은 컨트롤러에서 변경하기 전에 모델의 원본 데이터를 의미합니다. – spirit