Switched getting files with axios request to the api platform.

This commit is contained in:
krzysiej
2022-06-09 14:42:47 +02:00
parent 00820715ea
commit 67e970183f
5 changed files with 14 additions and 11 deletions

View File

@@ -111,13 +111,6 @@ class BookController extends AbstractController
]);
}
#[Route('/{id}/files', name: 'app_book_file', methods: ['GET'])]
public function files(Book $book): JsonResponse
{
return $this->json($book->getFiles(), context: [AbstractNormalizer::IGNORED_ATTRIBUTES => ['book']]);
}
#[Route('/{id}/edit', name: 'app_book_edit', methods: ['GET', 'POST'])]
public function edit(
Request $request,

View File

@@ -2,11 +2,14 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use App\Repository\BookRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: BookRepository::class)]
class Book
{
@@ -33,6 +36,7 @@ class Book
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $subtitle;
#[ApiSubresource]
#[ORM\OneToMany(mappedBy: 'book', targetEntity: File::class, orphanRemoval: true)]
private $files;