<?php
public function change()
{
$this->table('table_name')->addColumn('deleted_at', 'datetime', ['null' => true])->save();
} gedmo.listener.deleteable:
class: Gedmo\SoftDeleteable\SoftDeleteableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ '@annotation_reader' ] ]Adding the filter allows you to show or hide deleted records more easily. To use the filter by default, we use the enabled: true part.
orm:
# ...
filters:
deletableFilter:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true<?php
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
/**
* @ORM\Table()
* @ORM\Entity
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class TableName
{
use SoftDeleteableEntity;
# ...
}Sometimes you may need to access the deleted rows as well. To disable the filter for your query, use this following:
<?php
$em->getFilters()->disable('deletableFilter');