mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Added Doctrine Entities.
This commit is contained in:
parent
a0801afdbd
commit
160e826b51
20 changed files with 3400 additions and 1 deletions
111
src/Entity/Device.php
Normal file
111
src/Entity/Device.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class AttachmentType
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="devices")
|
||||
*/
|
||||
class Device extends PartsContainingDBElement
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
*/
|
||||
protected $order_quantity;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $order_only_missing_parts;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="DevicePart", mappedBy="device")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Get the order quantity of this device
|
||||
*
|
||||
* @return integer the order quantity
|
||||
*/
|
||||
public function getOrderQuantity() : int
|
||||
{
|
||||
return $this->order_quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "order_only_missing_parts" attribute
|
||||
*
|
||||
* @return boolean the "order_only_missing_parts" attribute
|
||||
*/
|
||||
public function getOrderOnlyMissingParts() : bool
|
||||
{
|
||||
return $this->order_only_missing_parts;
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Setters
|
||||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Set the order quantity
|
||||
*
|
||||
* @param integer $new_order_quantity the new order quantity
|
||||
*/
|
||||
public function setOrderQuantity(int $new_order_quantity)
|
||||
{
|
||||
if($new_order_quantity < 0)
|
||||
{
|
||||
throw new \InvalidArgumentException("The new order quantity must not be negative!");
|
||||
}
|
||||
$this->order_quantity = $new_order_quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "order_only_missing_parts" attribute
|
||||
*
|
||||
* @param boolean $new_order_only_missing_parts the new "order_only_missing_parts" attribute
|
||||
*
|
||||
*/
|
||||
public function setOrderOnlyMissingParts(bool $new_order_only_missing_parts)
|
||||
{
|
||||
$this->order_only_missing_parts = $new_order_only_missing_parts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
* @return string The ID as a string;
|
||||
*/
|
||||
public function getIDString(): string
|
||||
{
|
||||
return 'D' . sprintf('%09d', $this->getID());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue