At least it seems to be doing that.
First I retrieve multiple models:
$ConfirmedCards = JobCardHead::where('Status', '=', 'Confirmed')->get();
Then I use a for each loop to work on each model:
foreach ($ConfirmedCards as $card) {
...
}
Now each $card is a collection right? Laravel says that an eloquent model is extends the collection class and if I do,
foreach ($ConfirmedCards as $card) {
echo $card
}
I get the data in what definitely looks like a collection. But if I attempt to use the collection method put(), like this
foreach ($ConfirmedCards as $card) {
$card -> put('StartDate', 'someDate');
}
I get an error saying that I am trying to call put() on a query\\Builder instance, How is $card a builder instance?
Please Help. Thank you
Your $card variable is not a collection but an object extending Illuminate\\Database\\Eloquent\\Model class. When you try to echo this object, you're seeing it serialized to JSON .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.