Sure interesting post, but I'm against using eloquent when mass updating records as it updates one by one. I prefer to use update() on query builder, something like :
DB::table('posts')->where('published_at', '<', now())->update(['published_at' => now()]);
It will result query like this :
update `posts` set `published_at` = 2019-09-25 07:09:55 where `published_at` < 2019-09-25 07:09:55
This is indeed faster but be careful that your Observers wont be called with this method.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Sure interesting post, but I'm against using eloquent when mass updating records as it updates one by one. I prefer to use update() on query builder, something like :
It will result query like this :
This is indeed faster but be careful that your Observers wont be called with this method.