fix: 🐛 update check on menu node link values

This commit is contained in:
Alexis Gousseau 2024-10-16 11:03:38 +02:00
parent 0960963ec5
commit f5b38f3cf8
2 changed files with 8 additions and 8 deletions

View file

@ -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

View file

@ -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());
}
/**