<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface UserMerchantInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Model; | namespace Lc\ShopBundle\Model; | ||||
use App\Entity\OrderShop; | |||||
use App\Entity\UserMerchant; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
/** | /** | ||||
*/ | */ | ||||
abstract class CreditHistory extends AbstractEntity | abstract class CreditHistory extends AbstractEntity | ||||
{ | { | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="creditHistories") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $user; | |||||
/** | /** | ||||
* @ORM\Column(type="float") | * @ORM\Column(type="float") | ||||
*/ | */ | ||||
protected $amount; | protected $amount; | ||||
/** | |||||
* @ORM\Column(type="string", length=31) | |||||
*/ | |||||
protected $type; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=31) | * @ORM\Column(type="string", length=31) | ||||
*/ | */ | ||||
protected $comment; | protected $comment; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="creditHistories") | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserLerchantInterface", inversedBy="creditHistories") | |||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $orderShop; | |||||
public function getMerchant(): ?Merchant | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?Merchant $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getUser(): ?User | |||||
{ | |||||
return $this->user; | |||||
} | |||||
public function setUser(?User $user): self | |||||
{ | |||||
$this->user = $user; | |||||
return $this; | |||||
} | |||||
protected $userMerchant; | |||||
public function getAmount(): ?float | public function getAmount(): ?float | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getType(): ?string | |||||
{ | |||||
return $this->type; | |||||
} | |||||
public function setType(string $type): self | |||||
{ | |||||
$this->type = $type; | |||||
return $this; | |||||
} | |||||
public function getMeanPayment(): ?string | public function getMeanPayment(): ?string | ||||
{ | { | ||||
return $this->meanPayment; | return $this->meanPayment; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getOrderShop(): ?OrderShop | |||||
public function getUserMerchant(): ?UserMerchant | |||||
{ | { | ||||
return $this->orderShop; | |||||
return $this->userMerchant; | |||||
} | } | ||||
public function setOrderShop(?OrderShop $orderShop): self | |||||
public function setUserMerchant(?UserMerchant $userMerchant): self | |||||
{ | { | ||||
$this->orderShop = $orderShop; | |||||
$this->userMerchant = $userMerchant; | |||||
return $this; | return $this; | ||||
} | } |
*/ | */ | ||||
protected $userPointSales; | protected $userPointSales; | ||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserMerchantInterface", mappedBy="user", orphanRemoval=true) | |||||
*/ | |||||
protected $userMerchants; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->newsletters = new ArrayCollection(); | $this->newsletters = new ArrayCollection(); | ||||
$this->favoriteProductFamilies = new ArrayCollection(); | $this->favoriteProductFamilies = new ArrayCollection(); | ||||
$this->userPointSales = new ArrayCollection(); | $this->userPointSales = new ArrayCollection(); | ||||
$this->userMerchants = new ArrayCollection(); | |||||
} | } | ||||
public function getSummary() | public function getSummary() | ||||
{ | { | ||||
return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')'; | return strtoupper($this->getLastname()).' '.$this->getFirstname(). ' ('.$this->getEmail().')'; |
<?php | |||||
namespace Lc\ShopBundle\Model; | |||||
use App\Entity\CreditHistory; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\Common\Collections\Collection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
use Lc\ShopBundle\Context\CreditHistoryInterface; | |||||
/** | |||||
* @ORM\MappedSuperclass() | |||||
* | |||||
*/ | |||||
abstract class UserMerchant | |||||
{ | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userMerchants") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $user; | |||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | |||||
* @ORM\Column(type="float") | |||||
*/ | |||||
protected $credit ; | |||||
/** | |||||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="userMerchant", orphanRemoval=true) | |||||
*/ | |||||
protected $creditHistories; | |||||
public function __construct() | |||||
{ | |||||
$this->creditHistories = new ArrayCollection(); | |||||
} | |||||
public function getUser(): ?User | |||||
{ | |||||
return $this->user; | |||||
} | |||||
public function setUser(?User $user): self | |||||
{ | |||||
$this->user = $user; | |||||
return $this; | |||||
} | |||||
public function getMerchant(): ?Hub | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?Hub $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getCredit(): ?float | |||||
{ | |||||
return $this->credit; | |||||
} | |||||
public function setCredit(float $credit): self | |||||
{ | |||||
$this->credit = $credit; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @return Collection|CreditHistory[] | |||||
*/ | |||||
public function getCreditHistories(): Collection | |||||
{ | |||||
return $this->creditHistories; | |||||
} | |||||
public function addCreditHistory(CreditHistoryInterface $creditHistory): self | |||||
{ | |||||
if (!$this->creditHistories->contains($creditHistory)) { | |||||
$this->creditHistories[] = $creditHistory; | |||||
$creditHistory->setUserMerchant($this); | |||||
} | |||||
return $this; | |||||
} | |||||
public function removeCreditHistory(CreditHistoryInterface $creditHistory): self | |||||
{ | |||||
if ($this->creditHistories->contains($creditHistory)) { | |||||
$this->creditHistories->removeElement($creditHistory); | |||||
// set the owning side to null (unless already changed) | |||||
if ($creditHistory->getUserMerchant() === $this) { | |||||
$creditHistory->setUserMerchant(null); | |||||
} | |||||
} | |||||
return $this; | |||||
} | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Repository; | |||||
use App\Entity\UserMerchant; | |||||
use Lc\ShopBundle\Context\DefaultRepositoryInterface; | |||||
use Lc\ShopBundle\Repository\BaseRepository; | |||||
/** | |||||
* @method UserMerchant|null find($id, $lockMode = null, $lockVersion = null) | |||||
* @method UserMerchant|null findOneBy(array $criteria, array $orderBy = null) | |||||
* @method UserMerchant[] findAll() | |||||
* @method UserMerchant[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||||
*/ | |||||
class UserMerchantRepository extends BaseRepository implements DefaultRepositoryInterface | |||||
{ | |||||
public function getInterfaceClass() | |||||
{ | |||||
return UserMerchant::class; | |||||
} | |||||
} | |||||