| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace Webkul\BagistoApi\Models;
- use ApiPlatform\Metadata\ApiProperty;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\GetCollection;
- use ApiPlatform\Metadata\GraphQl\Query;
- use ApiPlatform\Metadata\GraphQl\QueryCollection;
- use Longyi\FrontMenu\Models\FrontMenuItem as BaseFrontMenuItem;
- use Webkul\BagistoApi\Resolver\BaseQueryItemResolver;
- use Webkul\BagistoApi\Resolver\FrontMenuTreeResolver;
- use Webkul\BagistoApi\State\CursorAwareCollectionProvider;
- #[ApiResource(
- routePrefix: '/api/shop',
- shortName: 'frontMenu',
- operations: [
- new Get(),
- new GetCollection(
- provider: CursorAwareCollectionProvider::class,
- paginationEnabled: true,
- paginationClientItemsPerPage: true,
- paginationItemsPerPage: 15,
- paginationMaximumItemsPerPage: 100,
- ),
- ],
- graphQlOperations: [
- new Query(resolver: BaseQueryItemResolver::class),
- new QueryCollection(provider: CursorAwareCollectionProvider::class),
- new QueryCollection(
- name: 'tree',
- paginationEnabled: false,
- resolver: FrontMenuTreeResolver::class,
- ),
- ],
- )]
- class FrontMenuItem extends BaseFrontMenuItem
- {
- /**
- * Unique identifier.
- */
- #[ApiProperty(identifier: true, writable: false)]
- public function getId(): int
- {
- return (int) $this->id;
- }
- /**
- * Menu name.
- */
- #[ApiProperty(readable: true, writable: false)]
- public function getName(): ?string
- {
- return $this->name;
- }
- /**
- * Unique slug.
- */
- #[ApiProperty(readable: true, writable: false)]
- public function getSlug(): ?string
- {
- 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;
- }
- /**
- * Children menu items (hierarchical).
- */
- #[ApiProperty(readableLink: true, writable: false, description: 'Child menu items')]
- public function getChildren()
- {
- return $this->children;
- }
- }
|