Код: Выделить всё
use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Table(name: 'user')]
#[ApiResource(
operations: [new GetCollection()],
normalizationContext: [
'groups' => [
'user:id',
'user:score',
'user:user_score',
],
]
)]
class User
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(name: 'ID_USER', type: 'integer')]
#[Groups(groups: ['user:id'])]
private int $id;
#[ORM\Column(name: 'SCORE', type: 'integer')]
#[Groups(groups: ['user:score'])]
private int $score;
#[ORM\Column(name: 'SCORE', type: 'integer')]
#[Groups(groups: ['user:user_score'])]
private int $userScore;
// getters / setters
}
Но я не могу сделать это за 1 шаг, мне нужно сделать первые два поля с одинаковым значением
а затем удалите ненужное поле
Как это сделать?
Подробнее здесь: https://stackoverflow.com/questions/787 ... n-database
Мобильная версия