コード例 #1
0
ファイル: ModelUser.php プロジェクト: skipperbent/pecee
 public function save(array $data = null)
 {
     if ($this->{$this->primary} === null) {
         $user = $this->instance()->filterUsername($this->username)->first();
         if ($user != null && $user->id != $this->id) {
             throw new UserException(sprintf('The username %s already exists', $this->data->username), static::ERROR_TYPE_EXISTS);
         }
     }
     parent::save($data);
 }
コード例 #2
0
ファイル: Source.php プロジェクト: Monori/imgservice
 public function save()
 {
     // Check if subdomain exists
     if (self::scalar('SELECT `id` FROM {table} WHERE `subdomain` = %s', $this->subdomain)) {
         throw new SourceException('Subdomain already exist');
     }
     parent::save();
     // Save cloudflare ids
     if (count($this->cloudflareIds)) {
         foreach ($this->cloudflareIds as $id) {
             $cloudflareRelation = new SourceCloudflare();
             $cloudflareRelation->source_id = $this->id;
             $cloudflareRelation->cloudflare_identifier = $id;
             $cloudflareRelation->save();
         }
     }
 }