当前位置: 首页>>代码示例>>PHP>>正文


PHP Account::exists方法代码示例

本文整理汇总了PHP中app\models\Account::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::exists方法的具体用法?PHP Account::exists怎么用?PHP Account::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Account的用法示例。


在下文中一共展示了Account::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // gte the requested subdomain
     $subdomain = getSubdomainFromHttpHost();
     // check that the account exists.
     if ($this->account->exists($subdomain)) {
         // add the account's subdomain to the request
         $request->account = $subdomain;
         // contimue on
         return $next($request);
     } else {
         // if it dosn't throw 404 error
         throw new HttpNotFoundException();
     }
 }
开发者ID:nicklaw5,项目名称:ticketing-system-api,代码行数:22,代码来源:AccountExistsMiddleware.php

示例2: 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'));
//.........这里部分代码省略.........
开发者ID:nicklaw5,项目名称:ticketing-system-api,代码行数:101,代码来源:AccountsController.php


注:本文中的app\models\Account::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。