Skip to content

Commit

Permalink
Fixing db
Browse files Browse the repository at this point in the history
Signed-off-by: AlexLalung <al@neomajes.com>
  • Loading branch information
AlexLalung committed Jul 15, 2014
1 parent d8d6954 commit f1e1e23
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 22 deletions.
21 changes: 21 additions & 0 deletions app/var/db/db-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,27 @@ INSERT INTO `user_data` (`id`, `update_date`, `create_date`) VALUES

-- --------------------------------------------------------

--
-- Structure de la table `user_address`
--

CREATE TABLE IF NOT EXISTS `user_address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`city` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`zipcode` int(11) NOT NULL,
`country` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`state` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`create_date` datetime NOT NULL,
`update_date` datetime NOT NULL,
PRIMARY KEY (`id`), ADD KEY `IDX_5543718BA76ED395` (`user_id`),
CONSTRAINT `FK_5543718BA76ED395` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Structure de la table `user_role`
--
Expand Down
59 changes: 37 additions & 22 deletions src/Majes/TeelBundle/Entity/UserAddress.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Majes\TeelBundle\Entity\User;
namespace Majes\TeelBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* UserAddress
*
* Majes\TeelBundle\Entity\UserAddress
* @ORM\Table(name="user_address")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class UserAddress {

Expand All @@ -22,7 +22,7 @@ class UserAddress {
private $id;

/**
* @ORM\ManyToOne(targetEntity="Majes\CoreBundle\Entity\User\User", inversedBy="address", cascade={"persist"})
* @ORM\ManyToOne(targetEntity="Majes\CoreBundle\Entity\User\User", inversedBy="addresses", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
Expand Down Expand Up @@ -72,16 +72,16 @@ class UserAddress {
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
* @ORM\Column(name="create_date", type="datetime")
*/
private $created;
private $createDate;

/**
* @var \DateTime
*
* @ORM\Column(name="updated", type="datetime")
* @ORM\Column(name="update_date", type="datetime")
*/
private $updated;
private $updateDate;

public function __construct() {
$this->created = new \DateTime();
Expand Down Expand Up @@ -244,47 +244,62 @@ public function getState() {
}

/**
* Set created
* Set createDate
*
* @param \DateTime $created
* @param \DateTime $createDate
*
* @return UserAddress
*/
public function setCreated($created) {
$this->created = $created;
public function setCreateDate($createDate) {
$this->createDate = $createDate;

return $this;
}

/**
* Get created
* Get createDate
*
* @return \DateTime
*/
public function getCreated() {
return $this->created;
public function getCreateDate() {
return $this->createDate;
}

/**
* Set updated
* Set updateDate
*
* @param \DateTime $updated
* @param \DateTime $updateDate
*
* @return UserAddress
*/
public function setUpdated($updated) {
$this->updated = $updated;
public function setUpdateDate($updateDate) {
$this->updateDate = $updateDate;

return $this;
}

/**
* Get updated
* Get updateDate
*
* @return \DateTime
*/
public function getUpdated() {
return $this->updated;
public function getUpdateDate() {
return $this->updateDate;
}

/**
*
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdateDate(new \DateTime(date('Y-m-d H:i:s')));

if($this->getCreateDate() == null)
{
$this->setCreateDate(new \DateTime(date('Y-m-d H:i:s')));
}
}

}

0 comments on commit f1e1e23

Please sign in to comment.