Tuesday, January 30, 2018

Laravel manually update timestamps returns null - development

Laravel manually update timestamps returns null

I have an offer with some children.

I want to update expire_time field of each children when their parent expire_time field changed.

but it returns null.

expire_time type is timestamps.

and here is my code in model:

if ($offer->childrenOffers->count()) {
        $offer->childrenOffers->each(function (self $childOffer) use($offer) {

            ddd($offer->expire_time); //returns "2018-02-30 23:59:59"
            ddd($childOffer->expire_time); //returns "2018-02-01 23:59:59"

            $childOffer->expire_time = $offer->expire_time;

            dd($childOffer->expire_time); //returns null

            $childOffer->save();
        });
    }

How can i do this ?!



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-manually-update-timestamps-returns-null/
via Lzo Media

1 comment:

  1. This above code is very important for me and i got this code from your article PHP development London | Laravel Development

    ReplyDelete