HIGHER ORDER MESSAGES
If we have a chunk of users and we want to update their `email_verified_at` we may write:
use \App\Models\User;
User::get()->each(function ($user) {
$user->update(['email_verified_at' => now()]);
});
But Laravel comes with an amazing feature called Higher Order Messages, which enables us to use some of its collection methods as if they were properties:
// \App\Http\Controllers\UserController.php use \App\Models\User;/** * Update the `email_verified_at` column of all registered users. */ public function updateEmailVerifiedAtOfAllUsers(): void { User::get()->each->update(['email_verified_at' => now()]); }
AI Assistant
Choose AI provider
Text Tools
Make content clear and easy to read
Have a Question?
Get clear answers based on this content