本文整理汇总了PHP中app\models\Account::isValidSubdomain方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::isValidSubdomain方法的具体用法?PHP Account::isValidSubdomain怎么用?PHP Account::isValidSubdomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Account
的用法示例。
在下文中一共展示了Account::isValidSubdomain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Create a new account
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request, ReservedSubdomain $reserved_subdomain)
{
// [
// "full_name" => "Nick Law"
// "organisation" => "Stryve Technologies"
// "subdomain" => "stryve-tech-123"
// "phone" => "0423 640 190"
// "email" => "nick@stryve.io"
// ]
// sanitize passed params and get geo data
$request = $this->account->sanitizeAndExpandRegistrationRequest($request);
dd($request);
// Check email address id valid
if (!isValidEmailAddress($request->email)) {
throw new HttpBadRequestException('Invalid email address.', 4002);
}
// check subdomain meets length and regex specifications
if (!$this->account->isValidSubdomain($request->subdomain)) {
throw new HttpBadRequestException('Invalid subdomain.', 4003);
}
// check subdomain is not already taken or reserved
if ($this->account->exists($request->subdomain) || $reserved_subdomain->isReserved($request->subdomain)) {
throw new HttpConflictException('Account already exists.', 4091);
}
// begin database transactions
DB::transaction(function () {
// create new user
// create new account
// create account email addresses
});
// set the connection options
$options = ['database' => $database, 'prefix' => $database_prefix];
// get the default connection detail so we can revert back
$defaultConnection = getDefaultDatabaseConnetion();
// set the new connection
setDatabaseConnetion($database, $options);
// create the new tenants database
$this->tenant->createNewTenantDatabase($database);
// run the new tenant migration
$this->tenant->runNewTenantMigration($database);
// \DB::disconnect($request->database);
// dd(\DB::connection('svr1'));
// run new tenant seeder
$this->tenant->runNewTenantTableSeeder($database);
// reset the default database connection
// setDatabaseConnetion($defaultConnection['connection'], $defaultConnection['options']);
// $default = \Config::get('database.default');
// dd(\Config::get('database.connections.' . $default));
exit('done');
// \DB::statement(\DB::raw('CREATE DATABASE ' . $request->database));
// \Artisan::call('migrate', [
// '--database' => $request->database,
// '--path' => 'app/Stryve/Database/Migrations/Tenant'
// ]);
//
/***/
// // Will contain the array of connections that appear in our database config file.
// $connections = \Config::get('database.connections');
// // This line pulls out the default connection by key (by default it's `mysql`)
// $defaultConnection = $connections[\Config::get('database.default')];
// // Now we simply copy the default connection information to our new connection.
// $newConnection = $defaultConnection;
// $options = [
// 'database' => $request->database,
// 'prefix' => $request->database_prefix
// ];
// // Override the database name.
// foreach($newConnection as $item => $value)
// $newConnection[$item] = isset($options[$item]) ? $options[$item] : $newConnection[$item];
// // dd($newConnection);
// // $newConnection['database'] = $request->database;
// // This will add our new connection to the run-time configuration for the duration of the request.
// \Config::set('database.connections.'.$request->database, $newConnection);
/***/
// count number of table from each database server
// select database server with the least number of databases
// // set the default connections options so we can revert back
// $conn_name = \Config::get('database.default');
// $defaultOptions = \Config::get('database.connections.'.$conn_name);
// // clone the default options
// $default = $defaultOptions;
// // the new conneciton options
// $options = [
// 'database' => $request->database,
// 'prefix' => $request->database_prefix
// ];
// // replace default options
// foreach($default as $item => $value)
// $default[$item] = isset($options[$item]) ? $options[$item] : $default[$item];
// // set the new connection
// \Config::set('database.connections.'.$conn_name, $default);
// try inserting new tenant DB
\DB::statement(\DB::raw('CREATE DATABASE ' . $request->database));
// dd(\Config::get('database.connections.db_svr_0'));
//.........这里部分代码省略.........