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; } } }
public static function assignRole($id, $type = '') { $type = $type === '' ? Config::get('role.sales') : $type; $staff = Static::find($id); $staff->roles()->attach($type); }