Beispiel #1
0
 public function save(array $options = [])
 {
     // If this is being set as the default primary group, then any other group must be demoted to default group
     if ($this->is_default == GROUP_DEFAULT_PRIMARY) {
         $current_default_primary = static::where('is_default', GROUP_DEFAULT_PRIMARY);
         // Exclude this object, if it exists in DB
         if ($this->id) {
             $current_default_primary = $current_default_primary->where('id', '!=', $this->id);
         }
         $current_default_primary->update(['is_default' => GROUP_DEFAULT]);
     }
     return parent::save($options);
 }
Beispiel #2
0
 /**
  * Store the User to the database, along with any group associations and new events, updating as necessary.
  *
  */
 public function save(array $options = [])
 {
     // Update the user record itself
     $result = parent::save($options);
     // Synchronize model's group relations with database
     $this->syncCachedGroups();
     // Save any new events for this user
     foreach ($this->new_events as $event) {
         $this->events()->save($event);
     }
     return $result;
 }
Beispiel #3
0
 public function save()
 {
     parent::save();
     if (strpos($this->alphaId, 'ZZZ') === FALSE) {
         return false;
     }
     $alpha1 = $this->originCity ? mb_substr($this->originCity, 0, 2) : 'X' . rand(1, 9);
     $alpha2 = $this->destinationCity ? mb_substr($this->destinationCity, 0, 2) : 'Y' . rand(1, 9);
     $number = 1;
     $alphaId = mb_strtoupper($alpha1 . '-' . str_pad($number, 2, "0", STR_PAD_LEFT) . '-' . $alpha2);
     while (self::alphaIdExists($alphaId, $this->user_id)) {
         $number++;
         $alphaId = mb_strtoupper($alpha1 . '-' . str_pad($number, 2, "0", STR_PAD_LEFT) . '-' . $alpha2);
     }
     $this->alphaId = $alphaId;
     return $this->save();
 }