Код: Выделить всё
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 шаг, мне нужно сделать первые 2 поля с одинаковым значением, а затем удалить ненужное поле.
Как это сделать?
Подробнее здесь: https://stackoverflow.com/questions/787 ... n-database
Мобильная версия