Example #1
0
 public function scopeExceptSubtreeById($q, $v = null)
 {
     if (!$v) {
         return $q;
     } else {
         $subtree = Static::find($v);
         if ($subtree->id) {
             return $q->where($this->getPathField(), 'not like', $subtree->ori_path . '%');
         } else {
             return $q;
         }
     }
 }
Example #2
0
 public static function assignRole($id, $type = '')
 {
     $type = $type === '' ? Config::get('role.sales') : $type;
     $staff = Static::find($id);
     $staff->roles()->attach($type);
 }