style; $string = 'children'; if (strpos($style, 'second') === 0) { $string .= '.children'; } else if (strpos($style, 'third') === 0) { $string .= '.children.children'; } return $string; } public function children() { return $this->hasMany(self::class, 'parent_id', 'id')->normal()->order('weigh', 'desc')->order('id', 'asc'); } }