Diferencia entre revisiones de «Agregar SoftDeleteable en un Entity en Smyfony»

De Wiki Proyectos Beta
Ir a la navegación Ir a la búsqueda
(feat: add Agregar SoftDeleteable en un Entity en Smyfony)
(feat: add Agregar SoftDeleteable en un Entity en Smyfony)
Línea 7: Línea 7:
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\ORM\Mapping as ORM;
  use Gedmo\Mapping\Annotation as Gedmo;
  use Gedmo\Mapping\Annotation as Gedmo;
  use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
  use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
   
   
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: false)]
  #[ORM\Entity(repositoryClass: UserRepository::class)]
  #[ORM\Entity(repositoryClass: UserRepository::class)]
  #[ORM\Table(name: '`user`')]
  #[ORM\Table(name: '`user`')]
#[Gedmo\SoftDeleteable]
  class User
  class User
  {
  {
     use SoftDeleteable;
     use SoftDeleteableEntity;
   
   
     #[ORM\Id]
     #[ORM\Id]

Revisión del 07:00 1 sep 2024

<?php

namespace App\Entity;

use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;

#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: false)]
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User
{
    use SoftDeleteableEntity;

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    ...

Migración

php bin/console make:migration
php bin/console doctrine:migrations:migrate