オブジェクト->push
上でlaravelオブジェクトに配列を追加しようとしていますが、機能していません。私は何が間違っているように見えますか?オブジェクトは変更されていません。
$cottages = Cottage::all();
foreach ($cottages as $cottage) {
//returns array
$gallery = $this->getCottageGallery($cottage['folder']);
//should append to $cottage object
$cottage->push($gallery);
}
dump($cottages);
私は実際$cottage->setAttribute('gallery', $gallery);
にそれをオブジェクトに割り当てるために使用しました!
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加