|
|
@@ -48,75 +48,23 @@ class FrontMenuItem extends BaseFrontMenuItem
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Menu name.
|
|
|
+ * Override the parent relationship to target the API resource model,
|
|
|
+ * so API Platform can resolve the self-referencing relation.
|
|
|
*/
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getName(): ?string
|
|
|
+ public function parent()
|
|
|
{
|
|
|
- return $this->name;
|
|
|
+ return $this->belongsTo(self::class, 'parent_id');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Unique slug.
|
|
|
+ * Override the children relationship to target the API resource model,
|
|
|
+ * so API Platform can resolve the self-referencing relation.
|
|
|
*/
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getSlug(): ?string
|
|
|
+ public function children()
|
|
|
{
|
|
|
- return $this->slug;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Menu URL.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getUrl(): ?string
|
|
|
- {
|
|
|
- return $this->url;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Menu image.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getImage(): ?string
|
|
|
- {
|
|
|
- return $this->image;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Menu banner.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getBanner(): ?string
|
|
|
- {
|
|
|
- return $this->banner;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Parent menu id.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getParentId(): ?int
|
|
|
- {
|
|
|
- return $this->parent_id ? (int) $this->parent_id : null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sort order.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getSortOrder(): int
|
|
|
- {
|
|
|
- return (int) $this->sort_order;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Status.
|
|
|
- */
|
|
|
- #[ApiProperty(readable: true, writable: false)]
|
|
|
- public function getStatus(): bool
|
|
|
- {
|
|
|
- return (bool) $this->status;
|
|
|
+ return $this->hasMany(self::class, 'parent_id')
|
|
|
+ ->orderBy('sort_order')
|
|
|
+ ->orderBy('id');
|
|
|
}
|
|
|
|
|
|
/**
|