Skip to content

Instantly share code, notes, and snippets.

@OwlyCode
Created October 18, 2019 11:06
Show Gist options
  • Save OwlyCode/a188766f0fb741ff24bdd3e8994805a1 to your computer and use it in GitHub Desktop.
Save OwlyCode/a188766f0fb741ff24bdd3e8994805a1 to your computer and use it in GitHub Desktop.
<?php
namespace App\Entity\Traits;
use App\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
trait BlameableTrait
{
/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="created_by", referencedColumnName="id")
*/
protected $createdBy;
/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="updated_by", referencedColumnName="id")
*/
protected $updatedBy;
public function setCreatedBy(User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setUpdatedBy(User $updatedBy): self
{
$this->updatedBy = $updatedBy;
return $this;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment