src/Entity/Restaurant.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\traits\base64Field;
  4. use App\Entity\traits\HasSlug;
  5. use App\Entity\traits\Timestapable;
  6. use App\Repository\RestaurantRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  12. use Doctrine\ORM\Mapping\PostLoad;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. #[ORM\Entity(repositoryClassRestaurantRepository::class)]
  15. #[HasLifecycleCallbacks]
  16. class Restaurant
  17. {
  18.     use Timestapable;
  19.     use base64Field;
  20.     use HasSlug;
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     #[Groups(["user_info""show_restaurant""show_dish"])]
  25.     private ?int $id null;
  26.     #[ORM\Column(length255)]
  27.     #[Groups(["user_info""show_restaurant""show_order""show_dish"])]
  28.     private ?string $name null;
  29.     #[Groups(["user_info""show_restaurant""show_order"])]
  30.     private $rateAverage;
  31.     #[Groups(["user_info""show_restaurant"])]
  32.     private $raterCount;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     #[Groups(["user_info""show_restaurant"])]
  35.     private ?string $slogan null;
  36.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  37.     #[Groups(["user_info""show_restaurant""show_order"])]
  38.     private ?string $description null;
  39.     #[ORM\Column(length255)]
  40.     #[Groups(["user_info""show_restaurant""show_order"])]
  41.     private ?string $dial_code null;
  42.     #[ORM\Column(length255nullabletrue)]
  43.     #[Groups(["user_info""show_restaurant""show_order"])]
  44.     private ?string $phone null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     #[Groups(["user_info""show_restaurant""show_order"])]
  47.     private ?string $email null;
  48.     #[ORM\Column(length255nullabletrue)]
  49.     #[Groups(["user_info""show_restaurant""show_order"])]
  50.     private ?string $contact1 null;
  51.     #[ORM\Column(length255nullabletrue)]
  52.     #[Groups(["user_info""show_restaurant"])]
  53.     private ?string $lat null;
  54.     #[ORM\Column(length255nullabletrue)]
  55.     #[Groups(["user_info""show_restaurant"])]
  56.     private ?string $lon null;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     #[Groups(["user_info""show_restaurant""show_order"])]
  59.     private ?string $country_code null;
  60.     #[ORM\Column(length255nullabletrue)]
  61.     #[Groups(["user_info""show_restaurant"])]
  62.     private ?string $country_name null;
  63.     #[ORM\Column(length255nullabletrue)]
  64.     #[Groups(["user_info""show_restaurant"])]
  65.     private ?string $town null;
  66.     #[ORM\Column(length255nullabletrue)]
  67.     #[Groups(["user_info""show_restaurant""show_order"])]
  68.     private ?string $city null;
  69.     #[ORM\ManyToOne(inversedBy'restaurants')]
  70.     #[Groups(["show_restaurant"])]
  71.     private ?User $owner null;
  72.     #[ORM\Column(length255nullabletrueoptions: ["default" => 'https://i.imgur.com/sJO7ysX.jpg'])]
  73.     #[Groups(["user_info""show_restaurant"])]
  74.     private ?string $imageUrl null;
  75.     
  76.     #[Groups(["user_info""show_restaurant"])]
  77.     private ?string $imageMiniature null;
  78.     #[ORM\OneToMany(mappedBy'restaurant'targetEntityRestaurantImage::class)]
  79.     #[Groups(["user_info""show_restaurant"])]
  80.     private Collection $restaurantImages;
  81.     #[ORM\OneToMany(mappedBy'restaurant'targetEntityDish::class)]
  82.     #[Groups(["user_info""show_restaurant"])]
  83.     private Collection $dishes;
  84.     #[ORM\OneToMany(mappedBy'restaurant'targetEntityRestaurantMenu::class)]
  85.     #[Groups(["user_info""show_restaurant"])]
  86.     private Collection $restaurantMenus;
  87.     #[ORM\OneToMany(mappedBy'restaurant'targetEntityRestaurantDish::class)]
  88.     #[Groups(["user_info""show_restaurant"])]
  89.     private Collection $restaurantDishes;
  90.     #[ORM\Column(options: ["default" => false])]
  91.     private ?bool $isSpotLight null;
  92.     #[ORM\Column(typeTypes::TEXToptions: ['default'=>""])]
  93.     #[Groups(["user_info""show_restaurant"])]
  94.     private ?string $aboutUs "";
  95.     #[ORM\Column(length255)]
  96.     #[Groups(["user_info""show_restaurant"])]
  97.     private ?string $chefImageUrl "";
  98.     #[ORM\Column(typeTypes::TEXToptions: ['default'=>""])]
  99.     #[Groups(["user_info""show_restaurant"])]
  100.     private ?string $chefDescription null;
  101.     #[ORM\OneToMany(mappedBy'resto'targetEntityOrder::class)]
  102.     // #[Groups(["user_info"])]
  103.     private Collection $orders;
  104.     #[ORM\Column(typeTypes::TEXT)]
  105.     #[Groups(["user_info""show_restaurant"])]
  106.     private ?string $aboutOurChief null;
  107.     #[ORM\Column(length255)]
  108.     #[Groups(["user_info""show_restaurant"])]
  109.     private ?string $chiefImage null;
  110.     #[ORM\ManyToMany(targetEntityRateRestaurant::class, mappedBy'restaurant')]
  111.     // #[Groups(["user_info", "show_restaurant"])]
  112.     private Collection $rateRestaurants;
  113.     #[ORM\Column(length255nullabletrue)]
  114.     #[Groups(["user_info""show_restaurant"])]
  115.     private ?string $chefName null;
  116.     #[ORM\Column(length255)]
  117.     #[Groups(["user_info","show_restaurant"])]
  118.     private ?string $scheduleStart "9:30";
  119.     #[ORM\Column(length255)]
  120.     #[Groups(["user_info","show_restaurant"])]
  121.     private ?string $scheduleEnd "19:00";
  122.     #[ORM\Column(length255)]
  123.     private ?string $address null;
  124.     #[ORM\Column(length255)]
  125.     private ?string $addressComp null;
  126.     #[ORM\Column]
  127.     #[Groups(["user_info","show_restaurant"])]
  128.     private ?bool $isValidedByAdmin null;
  129.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  130.     private ?\DateTimeInterface $AdminValidationDate null;
  131.     public function __construct()
  132.     {
  133.         $this->restaurantImages = new ArrayCollection();
  134.         $this->dishes = new ArrayCollection();
  135.         $this->restaurantMenus = new ArrayCollection();
  136.         $this->restaurantDishes = new ArrayCollection();
  137.         $this->orders = new ArrayCollection();
  138.         $this->rateRestaurants = new ArrayCollection();
  139.     }
  140.     public function getId(): ?int
  141.     {
  142.         return $this->id;
  143.     }
  144.     public function getName(): ?string
  145.     {
  146.         return $this->name;
  147.     }
  148.     public function setName(string $name): self
  149.     {
  150.         $this->name $name;
  151.         return $this;
  152.     }
  153.     public function getSlogan(): ?string
  154.     {
  155.         return $this->slogan;
  156.     }
  157.     public function setSlogan(string $slogan): self
  158.     {
  159.         $this->slogan $slogan;
  160.         return $this;
  161.     }
  162.     public function getDescription(): ?string
  163.     {
  164.         return $this->description;
  165.     }
  166.     public function setDescription(string $description): self
  167.     {
  168.         $this->description $description;
  169.         return $this;
  170.     }
  171.     public function getPhone(): ?string
  172.     {
  173.         return $this->phone;
  174.     }
  175.     public function setPhone(string $phone): self
  176.     {
  177.         $this->phone $phone;
  178.         return $this;
  179.     }
  180.     public function getEmail(): ?string
  181.     {
  182.         return $this->email;
  183.     }
  184.     public function setEmail(string $email): self
  185.     {
  186.         $this->email $email;
  187.         return $this;
  188.     }
  189.     public function getContact1(): ?string
  190.     {
  191.         return $this->contact1;
  192.     }
  193.     public function setContact1(?string $contact1): self
  194.     {
  195.         $this->contact1 $contact1;
  196.         return $this;
  197.     }
  198.     public function getLat(): ?string
  199.     {
  200.         return $this->lat;
  201.     }
  202.     public function setLat(?string $lat): self
  203.     {
  204.         $this->lat $lat;
  205.         return $this;
  206.     }
  207.     public function getLon(): ?string
  208.     {
  209.         return $this->lon;
  210.     }
  211.     public function setLon(string $lon): self
  212.     {
  213.         $this->lon $lon;
  214.         return $this;
  215.     }
  216.     public function getCountryCode(): ?string
  217.     {
  218.         return $this->country_code;
  219.     }
  220.     public function setCountryCode(string $country_code): self
  221.     {
  222.         $this->country_code $country_code;
  223.         return $this;
  224.     }
  225.     public function getCountryName(): ?string
  226.     {
  227.         return $this->country_name;
  228.     }
  229.     public function setCountryName(string $country_name): self
  230.     {
  231.         $this->country_name $country_name;
  232.         return $this;
  233.     }
  234.     public function getTown(): ?string
  235.     {
  236.         return $this->town;
  237.     }
  238.     public function setTown(string $town): self
  239.     {
  240.         $this->town $town;
  241.         return $this;
  242.     }
  243.     public function getCity(): ?string
  244.     {
  245.         return $this->city;
  246.     }
  247.     public function setCity(?string $city): self
  248.     {
  249.         $this->city $city;
  250.         return $this;
  251.     }
  252.     public function getOwner()
  253.     {
  254.         return $this->owner;
  255.     }
  256.     public function setOwner(?User $owner): self
  257.     {
  258.         $this->owner $owner;
  259.         return $this;
  260.     }
  261.     /**
  262.      * @return Collection<int, RestaurantImage>
  263.      */
  264.     public function getRestaurantImages(): Collection
  265.     {
  266.         return $this->restaurantImages;
  267.     }
  268.     public function addRestaurantImage(RestaurantImage $restaurantImage): self
  269.     {
  270.         if (!$this->restaurantImages->contains($restaurantImage)) {
  271.             $this->restaurantImages->add($restaurantImage);
  272.             $restaurantImage->setRestaurant($this);
  273.         }
  274.         return $this;
  275.     }
  276.     public function removeRestaurantImage(RestaurantImage $restaurantImage): self
  277.     {
  278.         if ($this->restaurantImages->removeElement($restaurantImage)) {
  279.             // set the owning side to null (unless already changed)
  280.             if ($restaurantImage->getRestaurant() === $this) {
  281.                 $restaurantImage->setRestaurant(null);
  282.             }
  283.         }
  284.         return $this;
  285.     }
  286.     public function getDialCode(): ?string
  287.     {
  288.         return $this->dial_code;
  289.     }
  290.     public function setDialCode(string $dial_code): self
  291.     {
  292.         $this->dial_code $dial_code;
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, Dish>
  297.      */
  298.     public function getDishes(): Collection
  299.     {
  300.         return $this->dishes;
  301.     }
  302.     public function addDish(Dish $dish): self
  303.     {
  304.         if (!$this->dishes->contains($dish)) {
  305.             $this->dishes->add($dish);
  306.             $dish->setRestaurant($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeDish(Dish $dish): self
  311.     {
  312.         if ($this->dishes->removeElement($dish)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($dish->getRestaurant() === $this) {
  315.                 $dish->setRestaurant(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.     public function getSlug(): ?string
  321.     {
  322.         return $this->slug;
  323.     }
  324.     public function setSlug(string $slug): self
  325.     {
  326.         $this->slug $slug;
  327.         return $this;
  328.     }
  329.     /**
  330.      * @return Collection<int, RestaurantMenu>
  331.      */
  332.     public function getRestaurantMenus(): Collection
  333.     {
  334.         return $this->restaurantMenus;
  335.     }
  336.     public function addRestaurantMenu(RestaurantMenu $restaurantMenu): self
  337.     {
  338.         if (!$this->restaurantMenus->contains($restaurantMenu)) {
  339.             $this->restaurantMenus->add($restaurantMenu);
  340.             $restaurantMenu->setRestaurant($this);
  341.         }
  342.         return $this;
  343.     }
  344.     public function removeRestaurantMenu(RestaurantMenu $restaurantMenu): self
  345.     {
  346.         if ($this->restaurantMenus->removeElement($restaurantMenu)) {
  347.             // set the owning side to null (unless already changed)
  348.             if ($restaurantMenu->getRestaurant() === $this) {
  349.                 $restaurantMenu->setRestaurant(null);
  350.             }
  351.         }
  352.         return $this;
  353.     }
  354.     /**
  355.      * @return Collection<int, RestaurantDish>
  356.      */
  357.     public function getRestaurantDishes(): Collection
  358.     {
  359.         return $this->restaurantDishes;
  360.     }
  361.     public function addRestaurantDish(RestaurantDish $restaurantDish): self
  362.     {
  363.         if (!$this->restaurantDishes->contains($restaurantDish)) {
  364.             $this->restaurantDishes->add($restaurantDish);
  365.             $restaurantDish->setRestaurant($this);
  366.         }
  367.         return $this;
  368.     }
  369.     public function removeRestaurantDish(RestaurantDish $restaurantDish): self
  370.     {
  371.         if ($this->restaurantDishes->removeElement($restaurantDish)) {
  372.             // set the owning side to null (unless already changed)
  373.             if ($restaurantDish->getRestaurant() === $this) {
  374.                 $restaurantDish->setRestaurant(null);
  375.             }
  376.         }
  377.         return $this;
  378.     }
  379.     /**
  380.      * Get the value of imageUrl
  381.      */
  382.     public function getImageUrl()
  383.     {
  384.         return $this->imageUrl;
  385.     }
  386.     /**
  387.      * Set the value of imageUrl
  388.      *
  389.      * @return  self
  390.      */
  391.     public function setImageUrl($imageUrl)
  392.     {
  393.         $this->imageUrl $imageUrl;
  394.         return $this;
  395.     }
  396.     public function isIsSpotLight(): ?bool
  397.     {
  398.         return $this->isSpotLight;
  399.     }
  400.     public function setIsSpotLight(bool $isSpotLight): self
  401.     {
  402.         $this->isSpotLight $isSpotLight;
  403.         return $this;
  404.     }
  405.     public function getAboutUs(): ?string
  406.     {
  407.         return $this->aboutUs;
  408.     }
  409.     public function setAboutUs(string $aboutUs): self
  410.     {
  411.         $this->aboutUs $aboutUs;
  412.         return $this;
  413.     }
  414.     public function getChefImageUrl(): ?string
  415.     {
  416.         return $this->chefImageUrl;
  417.     }
  418.     public function setChefImageUrl(string $chefImageUrl): self
  419.     {
  420.         $this->chefImageUrl $chefImageUrl;
  421.         return $this;
  422.     }
  423.     public function getChefDescription(): ?string
  424.     {
  425.         return $this->chefDescription;
  426.     }
  427.     public function setChefDescription(string $chefDescription): self
  428.     {
  429.         $this->chefDescription $chefDescription;
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return Collection<int, Order>
  434.      */
  435.     public function getOrders(): Collection
  436.     {
  437.         return $this->orders;
  438.     }
  439.     public function addOrder(Order $order): self
  440.     {
  441.         if (!$this->orders->contains($order)) {
  442.             $this->orders->add($order);
  443.             $order->setResto($this);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeOrder(Order $order): self
  448.     {
  449.         if ($this->orders->removeElement($order)) {
  450.             // set the owning side to null (unless already changed)
  451.             if ($order->getResto() === $this) {
  452.                 $order->setResto(null);
  453.             }
  454.         }
  455.         return $this;
  456.     }
  457.     public function getAboutOurChief(): ?string
  458.     {
  459.         return $this->aboutOurChief;
  460.     }
  461.     public function setAboutOurChief(string $aboutOurChief): self
  462.     {
  463.         $this->aboutOurChief $aboutOurChief;
  464.         return $this;
  465.     }
  466.     public function getChiefImage(): ?string
  467.     {
  468.         return $this->chiefImage;
  469.     }
  470.     public function setChiefImage(string $chiefImage): self
  471.     {
  472.         $this->chiefImage $chiefImage;
  473.         return $this;
  474.     }
  475.     /**
  476.      * @return Collection<int, RateRestaurant>
  477.      */
  478.     public function getRateRestaurants(): Collection
  479.     {
  480.         return $this->rateRestaurants;
  481.     }
  482.     #[PostLoad]
  483.     public function getRateAverage()
  484.     {
  485.         $rates $this->getRateRestaurants();
  486.         $rateSum 0;
  487.         $this->raterCount count($rates);
  488.         foreach ($rates as $rate) {
  489.             $rateSum += $rate->getNumberOfStart();
  490.         }
  491.         if(count($rates) != 0){
  492.             $average round($rateSum $this->raterCount1);
  493.         }else{
  494.             $average 0;
  495.         }   
  496.         $this->rateAverage $average;
  497.         return $this->rateAverage;
  498.     }
  499.     public function addRateRestaurant(RateRestaurant $rateRestaurant): self
  500.     {
  501.         if (!$this->rateRestaurants->contains($rateRestaurant)) {
  502.             $this->rateRestaurants->add($rateRestaurant);
  503.             $rateRestaurant->addRestaurant($this);
  504.         }
  505.         return $this;
  506.     }
  507.     public function removeRateRestaurant(RateRestaurant $rateRestaurant): self
  508.     {
  509.         if ($this->rateRestaurants->removeElement($rateRestaurant)) {
  510.             $rateRestaurant->removeRestaurant($this);
  511.         }
  512.         return $this;
  513.     }
  514.     public function getRaterCount (){
  515.          $this->raterCount;
  516.     }
  517.     /**
  518.      * Get the value of chefName
  519.      */ 
  520.     public function getChefName()
  521.     {
  522.         return $this->chefName;
  523.     }
  524.     /**
  525.      * Set the value of chefName
  526.      *
  527.      * @return  self
  528.      */ 
  529.     public function setChefName($chefName)
  530.     {
  531.         $this->chefName $chefName;
  532.         return $this;
  533.     }
  534.     public function getScheduleStart(): ?string
  535.     {
  536.         return $this->scheduleStart;
  537.     }
  538.     public function setScheduleStart(string $scheduleStart): self
  539.     {
  540.         $this->scheduleStart $scheduleStart;
  541.         return $this;
  542.     }
  543.     public function getScheduleEnd(): ?string
  544.     {
  545.         return $this->scheduleEnd;
  546.     }
  547.     public function setScheduleEnd(string $scheduleEnd): self
  548.     {
  549.         $this->scheduleEnd $scheduleEnd;
  550.         return $this;
  551.     }
  552.     public function getAddress(): ?string
  553.     {
  554.         return $this->address;
  555.     }
  556.     public function setAddress(string $address): self
  557.     {
  558.         $this->address $address;
  559.         return $this;
  560.     }
  561.     public function getAddressComp(): ?string
  562.     {
  563.         return $this->addressComp;
  564.     }
  565.     public function setAddressComp(string $addressComp): self
  566.     {
  567.         $this->addressComp $addressComp;
  568.         return $this;
  569.     }
  570.     public function isIsValidedByAdmin(): ?bool
  571.     {
  572.         return $this->isValidedByAdmin;
  573.     }
  574.     public function setIsValidedByAdmin(bool $isValidedByAdmin): self
  575.     {
  576.         $this->isValidedByAdmin $isValidedByAdmin;
  577.         return $this;
  578.     }
  579.     public function getAdminValidationDate(): ?\DateTimeInterface
  580.     {
  581.         return $this->AdminValidationDate;
  582.     }
  583.     public function setAdminValidationDate(\DateTimeInterface $AdminValidationDate): self
  584.     {
  585.         $this->AdminValidationDate $AdminValidationDate;
  586.         return $this;
  587.     }
  588.     public function getImageMiniature()
  589.     {
  590.         return $this->imageMiniature;
  591.     }
  592.  
  593.     public function setImageMiniature($imageMiniature)
  594.     {
  595.         $this->imageMiniature $imageMiniature;
  596.         return $this;
  597.     }
  598. }