コード例 #1
0
ファイル: WebsiteUser.php プロジェクト: hyn/webserver
 /**
  * @return bool
  */
 public function onUpdate()
 {
     if (!$this->exists()) {
         return $this->onCreate();
     } elseif ($this->name() && $this->website->isDirty('identifier')) {
         return $this->onRename($this->website->getOriginal('identifier'), $this->website->name());
     }
 }
コード例 #2
0
 /**
  * Writes the contents to disk on Update.
  *
  * @uses onCreate
  *
  * @return int
  */
 public function onUpdate()
 {
     if ($this->website->isDirty('identifier')) {
         $new = $this->website->identifier;
         $this->website->identifier = $this->website->getOriginal('identifier');
         $this->onDelete();
         $this->website->identifier = $new;
     }
     return $this->onCreate();
 }
コード例 #3
0
ファイル: Directory.php プロジェクト: Mobytes/multi-tenant
 public function __construct(Website $website)
 {
     $this->website = $website;
     if ($this->website->isDirty('identifier')) {
         $this->old_path = sprintf('%s/%d-%s/', Config::get('multi-tenant.tenant-directory') ? Config::get('multi-tenant.tenant-directory') : storage_path('multi-tenant'), $this->website->id, $this->website->getOriginal('identifier'));
         if (!File::isDirectory($this->old_path)) {
             $this->old_path = null;
         }
     }
     $this->base_path = sprintf('%s/%d-%s/', Config::get('multi-tenant.tenant-directory') ? Config::get('multi-tenant.tenant-directory') : storage_path('multi-tenant'), $this->website->id, $this->website->identifier);
 }
コード例 #4
0
 public function boot()
 {
     // configuration
     $this->mergeConfigFrom(__DIR__ . '/../config/webserver.php', 'webserver');
     $this->publishes([__DIR__ . '/../config/webserver.php' => config_path('webserver.php')], 'webserver-config');
     // adds views
     $this->loadViewsFrom(__DIR__ . '/../views', 'webserver');
     // migrations
     $this->publishes([__DIR__ . '/../database/migrations/' => database_path('/migrations')], 'migrations');
     Website::observe(new Observers\WebsiteObserver());
     SslCertificate::observe(new Observers\SslCertificateObserver());
     Hostname::observe(new Observers\HostnameObserver());
     /*
      * Ssl repository
      */
     $this->app->bind('Hyn\\Webserver\\Contracts\\SslRepositoryContract', function ($app) {
         return new SslRepository(new SslCertificate(), new SslHostname());
     });
     /*
      * Toolbox command
      */
     $this->app->bind('hyn.webserver.command.toolbox', function ($app) {
         return new Commands\ToolboxCommand($app->make(WebsiteRepositoryContract::class));
     });
     $this->commands(['hyn.webserver.command.toolbox']);
 }
コード例 #5
0
 /**
  * Generic configuration for tenant.
  *
  * @return array
  * @throws TenantDatabaseException
  * @throws \Laracasts\Presenter\Exceptions\PresenterException
  */
 protected function config()
 {
     $clone = Config::get(sprintf('database.connections.%s', static::systemConnectionName()));
     if (Config::get('multi-tenant.db.tenant-division-mode') == static::TENANT_MODE_SEPARATE_DATABASE) {
         $clone['password'] = md5(Config::get('app.key') . $this->website->id);
         $clone['username'] = $clone['database'] = sprintf('%d-%s', $this->website->id, $this->website->present()->identifier);
     } elseif (Config::get('multi-tenant.db.tenant-division-mode') == static::TENANT_MODE_TABLE_PREFIX) {
         $clone['prefix'] = sprintf('t%d_', $this->website->id);
     } else {
         throw new TenantDatabaseException('Unknown database division mode configured in the multi-tenant configuration file.');
     }
     return $clone;
 }
コード例 #6
0
 /**
  * Shows the delete website form.
  *
  * @param Website $website
  * @return \Illuminate\View\View
  */
 public function delete(Website $website)
 {
     $deleteRoute = route('management-interface.website.deleted', $website->present()->urlArguments);
     $name = $website->present()->name;
     return view('management-interface::layouts.delete', compact('website', 'deleteRoute', 'name'));
 }
コード例 #7
0
 /**
  * @param HostnameRepositoryContract $hostname
  * @param Website                    $website
  * @param $name
  *
  * @throws \Laracasts\Presenter\Exceptions\PresenterException
  *
  * @return $this|bool|\Hyn\Framework\Models\AbstractModel|null
  */
 public function added(HostnameRepositoryContract $hostname, Website $website, $name)
 {
     return (new HostnameValidator())->catchFormRequest($hostname->newInstance(), redirect()->route('management-interface.website.read', $website->present()->urlArguments));
 }
コード例 #8
0
 /**
  * Registers model observers.
  */
 protected function observers()
 {
     Models\Website::observe(new Observers\WebsiteObserver());
     Models\Hostname::observe(new Observers\HostnameObserver());
     Models\Tenant::observe(new Observers\TenantObserver());
 }
コード例 #9
0
 /**
  * Create a pagination object.
  *
  * @param int $per_page
  *
  * @return mixed
  */
 public function paginated($per_page = 20)
 {
     return $this->website->paginate($per_page);
 }