EntityTrait.php 474 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace common\traits;
  3. trait EntityTrait
  4. {
  5. public $entity;
  6. public $entityId;
  7. public function getEntityId()
  8. {
  9. if ($this->entityId == null) {
  10. $this->entityId = $this->owner->getPrimaryKey();
  11. }
  12. return $this->entityId;
  13. }
  14. public function getEntity()
  15. {
  16. if ($this->entity == null) {
  17. $this->entity = get_class($this->owner);
  18. }
  19. return ltrim($this->entity,"\\");
  20. }
  21. }