Switched getting files with axios request to the api platform.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user