diff --git a/app/Lib/Definitions/MenuNode.php b/app/Lib/Definitions/MenuNode.php index 5eb5614a..36035c81 100644 --- a/app/Lib/Definitions/MenuNode.php +++ b/app/Lib/Definitions/MenuNode.php @@ -33,21 +33,21 @@ class MenuNode extends \stdClass /** * Make and instance * - * @param integer $id The node menu id. - * @param integer $type The node menu type. - * @param boolean $published The node menu published. - * @param string $title The node menu title. - * @param array $link The node menu link. + * @param integer|null $id The node menu id. + * @param integer $type The node menu type. + * @param boolean $published The node menu published. + * @param string $title The node menu title. + * @param array $link The node menu link. * @return \App\Lib\Definitions\MenuNode * @throws \RuntimeException If $type or $data is wrong. */ - public static function make(int $id, int $type, bool $published, string $title, array $link): self + public static function make(?int $id, int $type, bool $published, string $title, array $link): self { self::assertTypeIsCorrect($type); $menuNode = new self(); // @phpstan-ignore-next-line - $menuNode->id = $id; + $menuNode->id = !is_null($id) ? $id : 1; // @phpstan-ignore-next-line $menuNode->type = MenuNodeType::make($type); // @phpstan-ignore-next-line diff --git a/app/Lib/Link.php b/app/Lib/Link.php index 4b63dde0..b021970a 100644 --- a/app/Lib/Link.php +++ b/app/Lib/Link.php @@ -60,7 +60,7 @@ class Link implements Jsonable, Arrayable, Stringable */ public function getUrl(): string { - return $this->url ?? !is_null($this->routeName) ? route($this->routeName) : '#'; + return !is_null($this->url) ? $this->url : route($this->getRouteName()); } /**