예제 #1
0
 /**
  * {@inheritDoc}
  */
 public static function boot()
 {
     parent::boot();
     // Setup event bindings...
     //UserGroup::observe(new UserGroupObserver);
     /**
      * Attach to the 'creating' Model Event to provide a UUID
      * for the `id` field (provided by $model->getKeyName())
      */
     static::saved(function ($model) {
         if (!$model->code) {
             $model->code = $model->generateCode();
             $model->save();
         }
     });
 }
 /**
  * See if the user is in the given group.
  * @param Group $group
  * @return bool
  */
 public function inGroup($group)
 {
     foreach ($this->getGroups() as $_group) {
         if ($_group->getKey() == $group->getKey()) {
             return true;
         }
     }
     return false;
 }