Commit 3d7a3676 authored by Александр Плохих's avatar Александр Плохих 🌔
Browse files

STA-1046 | fix listing clollection

parent 50ed0116
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2,7 +2,15 @@

namespace App\Restaurants\Collection;

class RestaurantLisitngElementCollection
use App\Restaurants\Dto\RestaurantListingElementDto;
use App\Shared\Collection\DtoCollection;

class RestaurantListingElementCollection extends DtoCollection
{
    private string $collectionType = RestaurantListingElementDto::class;

    public function __construct(array $data = [])
    {
        parent::__construct($this->collectionType, $data);
    }
}
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -2,19 +2,19 @@

namespace App\Restaurants\Dto;

use App\Shared\Collection\ListingCollection;
use App\Restaurants\Collection\RestaurantListingElementCollection;
use App\Shared\Dto\PaginationDto;

class RestaurantListDto
{
    /**
     * @param PaginationDto $pagination
     * @param ListingCollection<RestaurantListingElementDto> $list
     * @param RestaurantListingElementCollection<RestaurantListingElementDto> $list
     * @param RestaurantFilterVariantsDto $filterVariants
     */
    public function __construct(
        public PaginationDto $pagination,
        public ListingCollection $list,
        public RestaurantListingElementCollection $list,
        public RestaurantFilterVariantsDto $filterVariants,
    ) {}
}
+3 −3
Original line number Diff line number Diff line
@@ -2,23 +2,23 @@

namespace App\Restaurants\DtoFactory;

use App\Restaurants\Collection\RestaurantListingElementCollection;
use App\Restaurants\Dto\RestaurantFilterVariantsDto;
use App\Restaurants\Dto\RestaurantListDto;
use App\Restaurants\Dto\RestaurantListingElementDto;
use App\Shared\Collection\ListingCollection;
use App\Shared\Dto\PaginationDto;

class RestaurantListDtoFactory
{
    /**
     * @param PaginationDto $pagination
     * @param ListingCollection<RestaurantListingElementDto> $list
     * @param RestaurantListingElementCollection<RestaurantListingElementDto> $list
     * @param RestaurantFilterVariantsDto $filters
     * @return RestaurantListDto
     */
    public function create(
        PaginationDto $pagination,
        ListingCollection $list,
        RestaurantListingElementCollection $list,
        RestaurantFilterVariantsDto $filters
    ): RestaurantListDto {
        return new RestaurantListDto(
+4 −4
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

namespace App\Restaurants\DtoFactory;

use App\Restaurants\Collection\RestaurantListingElementCollection;
use App\Restaurants\Dto\RestaurantListingElementDto;
use App\Shared\Collection\ListingCollection;
use App\Shared\DtoFactory\FileDtoFactory;
use App\Shared\Entity\Restaurants;
use Ramsey\Collection\Collection;
@@ -29,14 +29,14 @@ class RestaurantListingElementDtoFactory

    /**
     * @param Collection<Restaurants> $restaurants
     * @return ListingCollection<RestaurantListingElementDto>
     * @return RestaurantListingElementCollection<RestaurantListingElementDto>
     */
    public function createCollection(Collection $restaurants): ListingCollection
    public function createCollection(Collection $restaurants): RestaurantListingElementCollection
    {
        $restaurantsDto = $restaurants->map(function(Restaurants $restaurant) {
            return $this->create($restaurant);
        });

        return new ListingCollection($restaurantsDto->toArray());
        return new RestaurantListingElementCollection($restaurantsDto->toArray());
    }
}