src/Controller/Project/ProjectPurchasesController.php line 24

Open in your IDE?
  1. <?php
  2. /*
  3.  * Created on Fri Dec 02 2022
  4.  *
  5.  * DAVID-OLIVIER DESCOMBES
  6.  *
  7.  * @licence
  8.  * You may not sell, sub-license, rent or lease any portion of the Software or Documentation to anyone.
  9.  *
  10.  * Copyright (c) 2022 dodarchitecte.com (https://dodarchitecte.com)
  11.  *
  12.  * Developed by developpeur-informatique.ma (https://www.developpeur-informatique.ma)
  13.  */
  14. namespace App\Controller\Project;
  15. use App\Entity\Project\Project;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\JsonResponse;
  18. use Symfony\Component\HttpKernel\Attribute\AsController;
  19. // use App\Service\FileUploader;
  20. #[AsController]
  21. final class ProjectPurchasesController extends AbstractController
  22. {
  23.     public function __invoke(Project $project): JsonResponse
  24.     {
  25.         $projectPurchases $project->getPurchases();
  26.         $purchases = [];
  27.         foreach ($projectPurchases as $purchase) {
  28.             $purchases[] = $purchase;
  29.         }
  30.         usort($purchases, function ($a$b) {
  31.             return $a->getId() < $b->getId();
  32.         });
  33.         // return $this->json($purchases, 200, []);
  34.         return $this->json($purchases200, [], ['groups' => ['Project:purchases']]);
  35.     }
  36. }