PHP version 5
Автор: XE Developers (developers@xpressengine.com)
Наследование: extends Xpressengine\Database\Eloquent\DynamicModel
Пример #1
0
 /**
  * Service Provider Boot
  *
  * @return void
  */
 public function boot()
 {
     if (app()->runningInConsole() === false) {
         /** @var Request $request */
         $request = app('request');
         $host = $request->getHttpHost();
         $host = $host . str_replace('/index.php', '', $request->server('SCRIPT_NAME'));
         $site = Site::where('host', $host)->first();
         app('xe.site')->setCurrentSite($site);
     }
 }
Пример #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $siteKey = $this->option('siteKey');
     $host = $this->option('host');
     $handler = $this->handler;
     try {
         $host = $this->validateHost($host);
         /** @var SiteModel $site */
         $site = SiteModel::find($siteKey);
         $site->host = $host;
         $handler->put($site);
         $this->comment($this->description);
     } catch (NotFoundSiteException $e) {
         $this->comment("Cannot find site information. (find key :{$siteKey})");
     } catch (InvalidArgumentException $e) {
         $this->comment("{$host} is incorrect host format. ex) example.com ");
     }
 }
Пример #3
0
 /**
  * put
  *
  * @param Site $site site object
  *
  * @return Site
  */
 public function put(Site $site)
 {
     if ($site->isDirty()) {
         $site->save();
     }
     return $site;
 }
Пример #4
0
 /**
  * update
  *
  * @param Site $site site entity object
  *
  * @return Site
  */
 public function update(Site $site)
 {
     $diff = $site->diff();
     if (count($diff) > 0) {
         $this->conn->table($this->table)->where('siteKey', $site->siteKey)->update($diff);
     }
     return $this->createModel(array_merge($site->getAttributes(), $diff));
 }