我對 API 平臺有疑問。我有一個產品實體和一個數量實體。我為我的 Angular 應用程序使用 API Platform 一個 API。一個產品可以有多個數量,一個數量只能有一個產品。在我的角度形式中,如果我創建一個鏈接到它工作的產品的數量(它是在數據庫中創建的)。之后,當我更新此產品時,這些先前的數量被刪除(即使我已將先前添加的數量的 IRI 添加到更新前的產品數量中)。這是一些代碼:數量.php<?phpnamespace App\Entity;use ApiPlatform\Core\Annotation\ApiResource;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use ApiPlatform\Core\Annotation\ApiFilter;use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;/** * @ApiResource() * @ApiFilter(OrderFilter::class, properties={"packing": "ASC"}) * @ORM\Entity(repositoryClass="App\Repository\QuantityRepository") */class Quantity{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity="App\Entity\Product", inversedBy="quantities") * @ORM\JoinColumn(nullable=false) */ private $product; /** * @ORM\ManyToOne(targetEntity="App\Entity\Ingredient") * @ORM\JoinColumn(nullable=false) */ private $ingredient; /** * @ORM\ManyToOne(targetEntity="App\Entity\Packing") * @ORM\JoinColumn(nullable=false) */ private $packing; /** * @ORM\Column(type="string", length=255) */ private $value;
添加回答
舉報
0/150
提交
取消