-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f15f136
commit 4043500
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use ApiPlatform\Metadata\ApiResource; | ||
|
||
/** | ||
* @ApiResource( | ||
* collectionOperations={ | ||
* "get", | ||
* "post" | ||
* }, | ||
* itemOperations={ | ||
* "get", | ||
* "put", | ||
* "delete", | ||
* "patch" | ||
* } | ||
* ) | ||
* @ORM\Entity() | ||
* @ORM\Table(name="toys") | ||
*/ | ||
|
||
// описываем класс Toy с атрибутами id, name, price, description. Прописываем геттеры и сеттеры атрибутов | ||
class Toy | ||
{ | ||
/** | ||
* @ORM\Id() | ||
* @ORM\GeneratedValue() | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @ORM\Column(type="string", length=255) | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private $price; | ||
|
||
/** | ||
* @ORM\Column(type="text") | ||
*/ | ||
private $description; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): self | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
public function getPrice(): ?int | ||
{ | ||
return $this->price; | ||
} | ||
|
||
public function setPrice(int $price): self | ||
{ | ||
$this->price = $price; | ||
|
||
return $this; | ||
} | ||
|
||
public function getDescription(): ?string | ||
{ | ||
return $this->description; | ||
} | ||
|
||
public function setDescription(string $description): self | ||
{ | ||
$this->description = $description; | ||
|
||
return $this; | ||
} | ||
} |