first(); return $parent ? $parent->toArray() : []; } /** * @Desc 获取所有子集 * @Author Gorden * @Date 2024/3/8 9:39 * * @param $id * @return array */ public function getDirectSub($id) { return self::where('category_pid', $id)->get()->toArray(); } /** * @Desc 更新path * @Author Gorden * @Date 2024/3/8 9:46 * * @param $id * @param $path * @return int */ public function updatePath($id, $path) { return self::where('category_id', $id)->update(['category_path' => $path]); } }