mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-09 18:04:33 +02:00
Added basic fields and migration for MySQL
This commit is contained in:
parent
e7e57fa412
commit
047c82791b
4 changed files with 138 additions and 0 deletions
|
@ -26,6 +26,7 @@ use App\Entity\Base\AbstractDBElement;
|
|||
use App\Entity\Base\TimestampTrait;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use App\Entity\Contracts\TimeStampableInterface;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Validator\Constraints\Selectable;
|
||||
use App\Validator\Constraints\ValidPartLot;
|
||||
use DateTime;
|
||||
|
@ -111,6 +112,13 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
*/
|
||||
protected Part $part;
|
||||
|
||||
/**
|
||||
* @var User|null The owner of this part lot
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
||||
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
protected ?User $owner;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if ($this->id) {
|
||||
|
@ -304,6 +312,28 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner of this part lot.
|
||||
* @return User|null
|
||||
*/
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the owner of this part lot.
|
||||
* @param User|null $owner
|
||||
* @return PartLot
|
||||
*/
|
||||
public function setOwner(?User $owner): PartLot
|
||||
{
|
||||
$this->owner = $owner;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->description;
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Entity\Parts;
|
|||
use App\Entity\Attachments\StorelocationAttachment;
|
||||
use App\Entity\Base\AbstractPartsContainingDBElement;
|
||||
use App\Entity\Parameters\StorelocationParameter;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
@ -89,6 +90,19 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
*/
|
||||
protected bool $limit_to_existing_parts = false;
|
||||
|
||||
/**
|
||||
* @var User|null The owner of this storage location
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\UserSystem\User")
|
||||
* @ORM\JoinColumn(name="id_owner", referencedColumnName="id", nullable=true, onDelete="SET NULL")
|
||||
*/
|
||||
protected ?User $owner;
|
||||
|
||||
/**
|
||||
* @var bool If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here.
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected bool $part_owner_must_match = false;
|
||||
|
||||
/**
|
||||
* @var Collection<int, StorelocationAttachment>
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\StorelocationAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
|
@ -166,6 +180,49 @@ class Storelocation extends AbstractPartsContainingDBElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner of this storage location
|
||||
* @return User|null
|
||||
*/
|
||||
public function getOwner(): ?User
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the owner of this storage location
|
||||
* @param User|null $owner
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setOwner(?User $owner): Storelocation
|
||||
{
|
||||
$this->owner = $owner;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here.
|
||||
* @return bool
|
||||
*/
|
||||
public function isPartOwnerMustMatch(): bool
|
||||
{
|
||||
return $this->part_owner_must_match;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is set to true, only parts lots, which are owned by the same user as the store location are allowed to be stored here.
|
||||
* @param bool $part_owner_must_match
|
||||
* @return Storelocation
|
||||
*/
|
||||
public function setPartOwnerMustMatch(bool $part_owner_must_match): Storelocation
|
||||
{
|
||||
$this->part_owner_must_match = $part_owner_must_match;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Setters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue