#database #development #laravel #php
toQuery method returns a query builder
instance using a
whereIn on the collection model's primary keys.
1use App\Models\User; 2 3$users = User::where('status', 'VIP')->get(); 4 5$users->toQuery()->update([ 6 'status' => 'Administrator', 7]);
This can be very useful when you want to update a large number of records without having to load them all into memory.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.