whereNotNull('secret')->eachById(function ($client): void { $secret = $client->secret; if (Hash::isHashed($secret) && ! Hash::needsRehash($secret)) { return; // Already hashed and not needing rehash } DB::table('oauth_clients') ->where('id', $client->id) ->update([ 'secret' => Hash::make($secret), ]); }); } /** * Reverse the migrations. */ public function down(): void { // This can not be reversed without a backup of the original secrets, for security reasons. } };