Created
September 18, 2014 14:45
-
-
Save anonymous/b3baaa8af2b90e421310 to your computer and use it in GitHub Desktop.
Orders Entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Entidad: Ordenes | |
* | |
* @package Tanane | |
* @subpackage ProductBundle | |
* @author Reynier Perez Mira <reynierpm@gmail.com> | |
* @copyright (c) Dynamo Technology Solutions | |
*/ | |
namespace Tanane\FrontendBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
use Gedmo\Timestampable\Traits\TimestampableEntity; | |
use Tanane\CommonBundle\Model\IdentifiedAutogeneratedEntityTrait; | |
use Tanane\FrontendBundle\DBAL\Types\SFType; | |
use Fresh\Bundle\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert; | |
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | |
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber; | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="orders") | |
* @ORM\Entity(repositoryClass="Tanane\FrontendBundle\Entity\Repository\OrdersRepository") | |
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) | |
*/ | |
class Orders { | |
use IdentifiedAutogeneratedEntityTrait; | |
/** | |
* Hook timestampable behavior | |
* updates createdAt, updatedAt fields | |
*/ | |
use TimestampableEntity; | |
/** | |
* @ORM\Column(name="nickname", type="string", length=150, nullable=true) | |
*/ | |
protected $nickname; | |
/** | |
* @AssertPhoneNumber(defaultRegion="VE") | |
* @ORM\Column(name="phone", type="phone_number", length=11) | |
*/ | |
protected $phone; | |
/** | |
* @ORM\Column(name="email", type="string", length=150, nullable=false) | |
*/ | |
protected $email; | |
/** | |
* @ORM\Column(name="fiscal_address", type="text", nullable=false) | |
*/ | |
protected $fiscal_address; | |
/** | |
* @ORM\Column(name="shipping_address", type="text", nullable=false) | |
*/ | |
protected $shipping_address; | |
/** | |
* @ORM\Column(name="shipping_from", type="shipping_from_type", nullable=false) | |
* @DoctrineAssert\Enum(entity="Tanane\FrontendBundle\DBAL\Types\SFType") | |
*/ | |
protected $shipping_from; | |
/** | |
* @ORM\ManyToOne(targetEntity="Tanane\CommonBundle\Entity\PaymentType") | |
* @ORM\JoinColumn(name="payment_type_id", referencedColumnName="id") | |
*/ | |
protected $payment_type; | |
/** | |
* @ORM\Column(name="order_amount", type="decimal", precision=6, scale=2, nullable=false) | |
*/ | |
protected $order_amount; | |
/** | |
* @ORM\ManyToOne(targetEntity="Tanane\CommonBundle\Entity\Bank") | |
* @ORM\JoinColumn(name="bank_id", referencedColumnName="id") | |
*/ | |
protected $bank; | |
/** | |
* @ORM\Column(name="transaction_id", type="string", length=150, nullable=false) | |
*/ | |
protected $transaction; | |
/** | |
* @ORM\Column(name="comments", type="text") | |
*/ | |
protected $comments; | |
/** | |
* @ORM\Column(name="secure", type="boolean") | |
*/ | |
protected $secure = false; | |
/** | |
* @ORM\Column(name="shipment_no", type="string", nullable=true, length=50) | |
*/ | |
protected $shipment_no; | |
/** | |
* @ORM\Column(name="invoice_no", type="string", nullable=true, length=50) | |
*/ | |
protected $invoice_no; | |
/** | |
* @ORM\ManyToOne(targetEntity="Person", inversedBy="orders") | |
* @ORM\JoinColumn(name="person_id", referencedColumnName="id") | |
* */ | |
protected $person; | |
/** | |
* @ORM\OneToMany(targetEntity="OrderHasProduct", mappedBy="order", cascade={"all"}) | |
*/ | |
protected $orderProducts; | |
protected $products; | |
/** | |
* @ORM\Column(name="deletedAt", type="datetime", nullable=true) | |
*/ | |
protected $deletedAt; | |
public function __construct() | |
{ | |
$this->orderProducts = new ArrayCollection(); | |
$this->products = new ArrayCollection(); | |
} | |
public function setNickname($nickname) | |
{ | |
$this->nickname = $nickname; | |
return $this; | |
} | |
public function getNickname() | |
{ | |
return $this->nickname; | |
} | |
public function setPhone($phone) | |
{ | |
$this->phone = $phone; | |
return $this; | |
} | |
public function getPhone() | |
{ | |
return $this->phone; | |
} | |
public function setEmail($email) | |
{ | |
$this->email = $email; | |
return $this; | |
} | |
public function getEmail() | |
{ | |
return $this->email; | |
} | |
public function setFiscalAddress($fiscal_address) | |
{ | |
$this->fiscal_address = $fiscal_address; | |
return $this; | |
} | |
public function getFiscalAddress() | |
{ | |
return $this->fiscal_address; | |
} | |
public function setShippingAddress($shipping_address) | |
{ | |
$this->shipping_address = $shipping_address; | |
return $this; | |
} | |
public function getShippingAddress() | |
{ | |
return $this->shipping_address; | |
} | |
public function setShippingFrom($shipping_from) | |
{ | |
$this->shipping_from = $shipping_from; | |
return $this; | |
} | |
public function getShippingFrom() | |
{ | |
return $this->shipping_from; | |
} | |
public function setPaymentType(\Tanane\CommonBundle\Entity\PaymentType $payment_type) | |
{ | |
$this->payment_type = $payment_type; | |
return $this; | |
} | |
public function getPaymentType() | |
{ | |
return $this->payment_type; | |
} | |
public function setOrderAmount($order_amount) | |
{ | |
$this->order_amount = $order_amount; | |
return $this; | |
} | |
public function getOrderAmount() | |
{ | |
return $this->order_amount; | |
} | |
public function setBank(\Tanane\CommonBundle\Entity\Bank $bank) | |
{ | |
$this->bank = $bank; | |
return $this; | |
} | |
public function getBank() | |
{ | |
return $this->bank; | |
} | |
public function setTransaction($transaction) | |
{ | |
$this->transaction = $transaction; | |
return $this; | |
} | |
public function getTransaction() | |
{ | |
return $this->transaction; | |
} | |
public function setSecure($secure) | |
{ | |
$this->secure = $secure; | |
return $this; | |
} | |
public function getSecure() | |
{ | |
return $this->secure; | |
} | |
public function setComments($comments) | |
{ | |
$this->comments = $comments; | |
return $this; | |
} | |
public function getComments() | |
{ | |
return $this->comments; | |
} | |
public function setShipmentNo($shipment_no = NULL) | |
{ | |
$this->shipment_no = $shipment_no; | |
return $this; | |
} | |
public function getShipmentNo() | |
{ | |
return $this->shipment_no; | |
} | |
public function setInvoiceNo($invoice_no = NULL) | |
{ | |
$this->invoice_no = $invoice_no; | |
return $this; | |
} | |
public function getInvoiceNo() | |
{ | |
return $this->invoice_no; | |
} | |
public function setPerson(Person $person) | |
{ | |
$this->person = $person; | |
return $this; | |
} | |
public function getPerson() | |
{ | |
return $this->person; | |
} | |
public function getOrderProducts() | |
{ | |
return $this->orderProducts; | |
} | |
public function getDeletedAt() | |
{ | |
return $this->deletedAt; | |
} | |
public function setDeletedAt($deletedAt) | |
{ | |
$this->deletedAt = $deletedAt; | |
} | |
public function getProduct() | |
{ | |
$products = new ArrayCollection(); | |
foreach ($this->orderProducts as $op) | |
{ | |
$products[] = $op->getProduct(); | |
} | |
return $products; | |
} | |
public function setProduct($products) | |
{ | |
foreach ($products as $p) | |
{ | |
$ohp = new OrderHasProduct(); | |
$ohp->setOrder($this); | |
$ohp->setProduct($p); | |
$this->addPo($ohp); | |
} | |
} | |
public function getOrder() | |
{ | |
return $this; | |
} | |
public function addPo($ProductOrder) | |
{ | |
$this->orderProducts[] = $ProductOrder; | |
} | |
public function removePo($ProductOrder) | |
{ | |
return $this->orderProducts->removeElement($ProductOrder); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment