-
-
Save JonTheWong/8fd0a3148e60e21d4792eada4153e847 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate uuids for clients and admins that don't have uuids set. | |
* | |
* The WHMCS 6.2.0 update process automatically inserts uuids, but if your | |
* installation bypasses WHMCS update routines then this will generate uuids for | |
* the client and admin users that don't have one yet. | |
* | |
* Warning! Please back up at least your tblclient and tbladmin tables before | |
* running this! | |
* | |
* Update by Jon Wong @JonTheWong / October 16th 2017 | |
* commented admin references, updated use location for Ramsey | |
* our implimentation is for importing csv data into the db and generating uuids. | |
*/ | |
/* use Rhumsaa\Uuid\Uuid; */ | |
use Ramsey\Uuid\Uuid; | |
/* use WHMCS\User\Admin; */ | |
use WHMCS\User\Client; | |
require_once __DIR__ . '/init.php'; | |
// Look for client and admin users with empty uuids. | |
$clients = Client::where('uuid', '')->get(); | |
/* $admins = Admin::where('uuid', '')->get(); */ | |
var_dump('Found ' . $clients->count() . ' client(s) with no uuid.'); | |
/* var_dump('Found ' . $admins->count() . ' admin(s) with no uuid.'); */ | |
// Generate uuids for clients. | |
$clients->each(function (Client $client) { | |
$client->uuid = Uuid::uuid4(); | |
$client->save(); | |
var_dump('Generated uuid ' . $client->uuid . ' for client id ' . $client->id); | |
}); | |
// Generate uuids for admins. | |
/* $admins->each(function (Admin $admin) { | |
$admin->uuid = Uuid::uuid4(); | |
$admin->save(); | |
var_dump('Generated uuid ' . $admin->uuid . ' for admin id ' . $admin->id); | |
}); */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment