src/CoreBundle/Entity/Vehicles/Vehicle.php line 19

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity\Vehicles;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Application\Sonata\MediaBundle\Entity\Media;
  5. use Application\Sonata\MediaBundle\Entity\Gallery;
  6. use CoreBundle\Entity\User;
  7. use CoreBundle\Entity\Dealer;
  8. use CoreBundle\Entity\Model;
  9. use CoreBundle\Entity\Post;
  10. use DateTime;
  11. use CoreBundle\Entity\AutoRiaOptions;
  12. use Doctrine\Common\Collections\Collection;
  13. /**
  14.  * Vehicle
  15.  */
  16. class Vehicle
  17. {
  18.     /**
  19.      * @var integer
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var integer
  24.      */
  25.     private $temp_id;
  26.     /**
  27.      * @var string
  28.      */
  29.     private $admin_name;
  30.     /**
  31.      * @var DateTime
  32.      */
  33.     private $date_create;
  34.     /**
  35.      * @var integer
  36.      */
  37.     private $vehicle_type;
  38.     /**
  39.      * @var string
  40.      */
  41.     private $url;
  42.     /**
  43.      * @var string
  44.      */
  45.     private $vin;
  46.     /**
  47.      * @var integer
  48.      */
  49.     private $state 1;
  50.     /**
  51.      * @var integer
  52.      */
  53.     private $show_disabled;
  54.     /**
  55.      * @var integer
  56.      */
  57.     private $position 0;
  58.     /**
  59.      * @var string
  60.      */
  61.     private $test_drive 0;
  62.     /**
  63.      * @var integer
  64.      */
  65.     private $credit_available 0;
  66.     /**
  67.      * @var integer
  68.      */
  69.     private $recommend;
  70.     /**
  71.      * @var integer
  72.      */
  73.     private $is_new_model;
  74.     /**
  75.      * @var integer
  76.      */
  77.     private $is_used 0;
  78.     /**
  79.      * @var integer
  80.      */
  81.     private $has_nds 0;
  82.     /**
  83.      * @var Media
  84.      */
  85.     private $image;
  86.     /**
  87.      * @var Media
  88.      */
  89.     private $preview;
  90.     /**
  91.      * @var Media
  92.      */
  93.     private $preview_second;
  94.     /**
  95.      * @var Gallery
  96.      */
  97.     private $gallery;
  98.     /**
  99.      * @var Gallery
  100.      */
  101.     private $video;
  102.     /**
  103.      * @var VehicleCardType|null
  104.      */
  105.     private $vehicleCardType;
  106.     /**
  107.      * @var Collection
  108.      */
  109.     private $files;
  110.     /**
  111.      * @var Collection
  112.      */
  113.     private $content;
  114.     /**
  115.      * @var Collection
  116.      */
  117.     private $equipments;
  118.     /**
  119.      * @var Collection
  120.      */
  121.     private $features;
  122.     /**
  123.      * @var Collection
  124.      */
  125.     private $variations;
  126.     /**
  127.      * @var User
  128.      */
  129.     private $creator;
  130.     /**
  131.      * @var Dealer
  132.      */
  133.     private $dealer;
  134.     /**
  135.      * @var Model
  136.      */
  137.     private $model;
  138.     /**
  139.      * @var Category
  140.      */
  141.     private $category;
  142.     /**
  143.      * @var Group
  144.      */
  145.     private $group;
  146.     /**
  147.      * @var Collection
  148.      */
  149.     private $posts;
  150.     /**
  151.      * @var Collection
  152.      */
  153.     private $colors;
  154.     /**
  155.      * @var Collection
  156.      */
  157.     private $interiers;
  158.     /**
  159.      * @var Collection
  160.      */
  161.     private $vehicle_items;
  162.     /**
  163.      * @var integer
  164.      */
  165.     private $ria_level;
  166.     /**
  167.      * @var integer
  168.      */
  169.     private $ria_period;
  170.     /**
  171.      * @var DateTime
  172.      */
  173.     private $ria_publication_date;
  174.     /**
  175.      * @var DateTime
  176.      */
  177.     private $ria_top_publication_date;
  178.     /**
  179.      * @var integer
  180.      */
  181.     private $ria_is_notified;
  182.     /**
  183.      * @var string
  184.      */
  185.     private $crm_id;
  186.     /**
  187.      * @var integer
  188.      */
  189.     private $is_not_filled 0;
  190.     /**
  191.      * @var integer
  192.      */
  193.     private $is_pre_order 0;
  194.     /**
  195.      * @var Collection
  196.      */
  197.     private $boat_engine;
  198.     /**
  199.      * @var Collection
  200.      */
  201.     private $auto_ria_options;
  202.     private DateTime $updatedAt;
  203.     /**
  204.      * @var Collection
  205.      */
  206.     private $vehicle_auto_ria_options;
  207.     /**
  208.      * Constructor
  209.      */
  210.     public function __construct()
  211.     {
  212.         $this->files = new ArrayCollection();
  213.         $this->content = new ArrayCollection();
  214.         $this->equipments = new ArrayCollection();
  215.         $this->features = new ArrayCollection();
  216.         $this->vehicle_items = new ArrayCollection();
  217.         $this->variations = new ArrayCollection();
  218.         $this->posts = new ArrayCollection();
  219.         $this->faqs = new ArrayCollection();
  220.         $this->colors = new ArrayCollection();
  221.         $this->interiers = new ArrayCollection();
  222.         $this->vehicle_auto_ria_options = new ArrayCollection();
  223.         $this->content->add((new VehicleContent())->setLanguage('ru')->setVehicle($this));
  224.         $this->content->add((new VehicleContent())->setLanguage('ua')->setVehicle($this));
  225.     }
  226.     public function __sleep()
  227.     {
  228.         return ['content''equipments''variations''vehicle_items''state''features'];
  229.     }
  230.     public function prepareDataForSerialization()
  231.     {
  232.         $data = [
  233.             'content' => [
  234.                 'ru' => $this->getContentByLocale('ru'),
  235.                 'ua' => $this->getContentByLocale('ua'),
  236.             ],
  237.             'equipments' => [],
  238.             'variations' => [],
  239.             'items' => [],
  240.         ];
  241.         foreach ($this->getArrayEquipments() as $equipment) {
  242.             $data['equipments'][] = ['id' => $equipment->getId(), 'title' => $equipment->getTitle()];
  243.         }
  244.         foreach ($this->getArrayVariations() as $variation) {
  245.             $data['variations'][] = ['id' => $variation->getId(), 'title' => $variation->getTitle()];
  246.         }
  247.         foreach ($this->getArrayVehicleItems() as $vehicleItem) {
  248.             $data['items'][] = [
  249.                 'id' => $vehicleItem->getId(),
  250.                 'equipment' => $vehicleItem->getEquipment() ? $vehicleItem->getEquipment()->getId() : null,
  251.                 'variation' => $vehicleItem->getVariation() ? $vehicleItem->getVariation()->getId() : null,
  252.                 'price' => $vehicleItem->getPrice(),
  253.                 'PreorderPrice' => $vehicleItem->getPreorderPrice(),
  254.                 'PriceWithPDV' => $vehicleItem->getPriceWithPDV(),
  255.                 'SpecifyPrice' => $vehicleItem->getSpecifyPrice(),
  256.                 'AltPrice' => $vehicleItem->getAltPrice(),
  257.                 'BestPrice' => $vehicleItem->getBestPrice(),
  258.                 'RentPrice' => $vehicleItem->getRentPrice(),
  259.                 'AltUsdPrice' => $vehicleItem->getAltUsdPrice(),
  260.                 'AltRate' => $vehicleItem->getAltRate(),
  261.             ];
  262.         }
  263.         $data['state'] = $this->getState();
  264.         return $data;
  265.     }
  266.     /**
  267.      * Get id
  268.      *
  269.      * @return integer
  270.      */
  271.     public function getId()
  272.     {
  273.         return $this->id;
  274.     }
  275.     /**
  276.      * Set tempId
  277.      *
  278.      * @param integer $tempId
  279.      *
  280.      * @return Vehicle
  281.      */
  282.     public function setTempId($tempId)
  283.     {
  284.         $this->temp_id $tempId;
  285.         return $this;
  286.     }
  287.     /**
  288.      * Get tempId
  289.      *
  290.      * @return integer
  291.      */
  292.     public function getTempId()
  293.     {
  294.         return $this->temp_id;
  295.     }
  296.     /**
  297.      * Set dateCreate
  298.      *
  299.      * @param DateTime $dateCreate
  300.      *
  301.      * @return Vehicle
  302.      */
  303.     public function setDateCreate($dateCreate)
  304.     {
  305.         $this->date_create $dateCreate;
  306.         return $this;
  307.     }
  308.     /**
  309.      * Get dateCreate
  310.      *
  311.      * @return DateTime
  312.      */
  313.     public function getDateCreate()
  314.     {
  315.         return $this->date_create;
  316.     }
  317.     /**
  318.      * Set vehicleType
  319.      *
  320.      * @param integer $vehicleType
  321.      *
  322.      * @return Vehicle
  323.      */
  324.     public function setVehicleType($vehicleType)
  325.     {
  326.         $this->vehicle_type $vehicleType;
  327.         return $this;
  328.     }
  329.     /**
  330.      * Get vehicleType
  331.      *
  332.      * @return integer
  333.      */
  334.     public function getVehicleType()
  335.     {
  336.         return $this->vehicle_type;
  337.     }
  338.     /**
  339.      * Set url
  340.      *
  341.      * @param string $url
  342.      *
  343.      * @return Vehicle
  344.      */
  345.     public function setUrl($url)
  346.     {
  347.         $this->url $url;
  348.         return $this;
  349.     }
  350.     /**
  351.      * Get url
  352.      *
  353.      * @return string
  354.      */
  355.     public function getUrl()
  356.     {
  357.         return $this->url;
  358.     }
  359.     /**
  360.      * Set vin
  361.      *
  362.      * @param string $vin
  363.      *
  364.      * @return Vehicle
  365.      */
  366.     public function setVin($vin)
  367.     {
  368.         $this->vin $vin;
  369.         return $this;
  370.     }
  371.     /**
  372.      * Get vin
  373.      *
  374.      * @return string
  375.      */
  376.     public function getVin()
  377.     {
  378.         return $this->vin;
  379.     }
  380.     /**
  381.      * Set state
  382.      *
  383.      * @param integer $state
  384.      *
  385.      * @return Vehicle
  386.      */
  387.     public function setState($state)
  388.     {
  389.         $this->state $state;
  390.         return $this;
  391.     }
  392.     /**
  393.      * Get state
  394.      *
  395.      * @return integer
  396.      */
  397.     public function getState()
  398.     {
  399.         return $this->state 0;
  400.     }
  401.     /**
  402.      * Set showDisabled
  403.      *
  404.      * @param integer $showDisabled
  405.      *
  406.      * @return Vehicle
  407.      */
  408.     public function setShowDisabled($showDisabled)
  409.     {
  410.         $this->show_disabled $showDisabled;
  411.         return $this;
  412.     }
  413.     /**
  414.      * Get showDisabled
  415.      *
  416.      * @return integer
  417.      */
  418.     public function getShowDisabled()
  419.     {
  420.         return $this->show_disabled 0;
  421.     }
  422.     /**
  423.      * Set position
  424.      *
  425.      * @param integer $position
  426.      *
  427.      * @return Vehicle
  428.      */
  429.     public function setPosition($position)
  430.     {
  431.         $this->position $position;
  432.         return $this;
  433.     }
  434.     /**
  435.      * Get position
  436.      *
  437.      * @return integer
  438.      */
  439.     public function getPosition()
  440.     {
  441.         return $this->position;
  442.     }
  443.     /**
  444.      * Set testDrive
  445.      *
  446.      * @param string $testDrive
  447.      *
  448.      * @return Vehicle
  449.      */
  450.     public function setTestDrive($testDrive)
  451.     {
  452.         $this->test_drive $testDrive;
  453.         return $this;
  454.     }
  455.     /**
  456.      * Get testDrive
  457.      *
  458.      * @return string
  459.      */
  460.     public function getTestDrive()
  461.     {
  462.         return $this->test_drive 0;
  463.     }
  464.     /**
  465.      * Set creditAvailable
  466.      *
  467.      * @param integer $creditAvailable
  468.      *
  469.      * @return Vehicle
  470.      */
  471.     public function setCreditAvailable($creditAvailable)
  472.     {
  473.         $this->credit_available $creditAvailable;
  474.         return $this;
  475.     }
  476.     /**
  477.      * Get creditAvailable
  478.      *
  479.      * @return integer
  480.      */
  481.     public function getCreditAvailable()
  482.     {
  483.         return $this->credit_available 0;
  484.     }
  485.     /**
  486.      * Set recommend
  487.      *
  488.      * @param integer $recommend
  489.      *
  490.      * @return Vehicle
  491.      */
  492.     public function setRecommend($recommend)
  493.     {
  494.         $this->recommend $recommend;
  495.         return $this;
  496.     }
  497.     /**
  498.      * Get recommend
  499.      *
  500.      * @return integer
  501.      */
  502.     public function getRecommend()
  503.     {
  504.         return $this->recommend 0;
  505.     }
  506.     /**
  507.      * Set isNewModel
  508.      *
  509.      * @param integer $isNewModel
  510.      *
  511.      * @return Vehicle
  512.      */
  513.     public function setIsNewModel($isNewModel)
  514.     {
  515.         $this->is_new_model $isNewModel;
  516.         return $this;
  517.     }
  518.     /**
  519.      * Get isNewModel
  520.      *
  521.      * @return integer
  522.      */
  523.     public function getIsNewModel()
  524.     {
  525.         return $this->is_new_model 0;
  526.     }
  527.     /**
  528.      * Set isUsed
  529.      *
  530.      * @param integer $isUsed
  531.      *
  532.      * @return Vehicle
  533.      */
  534.     public function setIsUsed($isUsed)
  535.     {
  536.         $this->is_used $isUsed;
  537.         return $this;
  538.     }
  539.     /**
  540.      * Get isUsed
  541.      *
  542.      * @return integer
  543.      */
  544.     public function getIsUsed()
  545.     {
  546.         return $this->is_used 0;
  547.     }
  548.     /**
  549.      * Set hasNds
  550.      *
  551.      * @param integer $hasNds
  552.      *
  553.      * @return Vehicle
  554.      */
  555.     public function setHasNds($hasNds)
  556.     {
  557.         $this->has_nds $hasNds;
  558.         return $this;
  559.     }
  560.     /**
  561.      * Get hasNds
  562.      *
  563.      * @return integer
  564.      */
  565.     public function getHasNds()
  566.     {
  567.         return $this->has_nds 0;
  568.     }
  569.     /**
  570.      * Set image
  571.      *
  572.      * @param Media $image
  573.      *
  574.      * @return Vehicle
  575.      */
  576.     public function setImage(Media $image null)
  577.     {
  578.         $this->image $image;
  579.         return $this;
  580.     }
  581.     /**
  582.      * Get image
  583.      *
  584.      * @return Media
  585.      */
  586.     public function getImage()
  587.     {
  588.         return $this->image;
  589.     }
  590.     /**
  591.      * Set preview
  592.      *
  593.      * @param Media $preview
  594.      *
  595.      * @return Vehicle
  596.      */
  597.     public function setPreview(Media $preview null)
  598.     {
  599.         $this->preview $preview;
  600.         return $this;
  601.     }
  602.     /**
  603.      * Get preview
  604.      *
  605.      * @return Media
  606.      */
  607.     public function getPreview()
  608.     {
  609.         return $this->preview;
  610.     }
  611.     /**
  612.      * Set previewSecond
  613.      *
  614.      * @param Media $previewSecond
  615.      *
  616.      * @return Vehicle
  617.      */
  618.     public function setPreviewSecond(Media $previewSecond null)
  619.     {
  620.         $this->preview_second $previewSecond;
  621.         return $this;
  622.     }
  623.     /**
  624.      * Get previewSecond
  625.      *
  626.      * @return Media
  627.      */
  628.     public function getPreviewSecond()
  629.     {
  630.         return $this->preview_second;
  631.     }
  632.     /**
  633.      * Set gallery
  634.      *
  635.      * @param Gallery $gallery
  636.      *
  637.      * @return Vehicle
  638.      */
  639.     public function setGallery(Gallery $gallery null)
  640.     {
  641.         $this->gallery $gallery;
  642.         return $this;
  643.     }
  644.     /**
  645.      * Get gallery
  646.      *
  647.      * @return Gallery
  648.      */
  649.     public function getGallery()
  650.     {
  651.         return $this->gallery;
  652.     }
  653.     /**
  654.      * Set video
  655.      *
  656.      * @param Gallery $video
  657.      *
  658.      * @return Vehicle
  659.      */
  660.     public function setVideo(Gallery $video null)
  661.     {
  662.         $this->video $video;
  663.         return $this;
  664.     }
  665.     /**
  666.      * Get video
  667.      *
  668.      * @return Gallery
  669.      */
  670.     public function getVideo()
  671.     {
  672.         return $this->video;
  673.     }
  674.     /**
  675.      * Add file
  676.      *
  677.      * @param VehicleFile $file
  678.      *
  679.      * @return Vehicle
  680.      */
  681.     public function addFile(VehicleFile $file)
  682.     {
  683.         $this->files[] = $file;
  684.         return $this;
  685.     }
  686.     /**
  687.      * Remove file
  688.      *
  689.      * @param VehicleFile $file
  690.      */
  691.     public function removeFile(VehicleFile $file)
  692.     {
  693.         $this->files->removeElement($file);
  694.     }
  695.     /**
  696.      * Get files
  697.      *
  698.      * @return Collection
  699.      */
  700.     public function getFiles()
  701.     {
  702.         return $this->files;
  703.     }
  704.     /**
  705.      * Add content
  706.      *
  707.      * @param VehicleContent $content
  708.      *
  709.      * @return Vehicle
  710.      */
  711.     public function addContent(VehicleContent $content)
  712.     {
  713.         $this->content[] = $content;
  714.         return $this;
  715.     }
  716.     /**
  717.      * Remove content
  718.      *
  719.      * @param VehicleContent $content
  720.      */
  721.     public function removeContent(VehicleContent $content)
  722.     {
  723.         $this->content->removeElement($content);
  724.     }
  725.     /**
  726.      * Get content
  727.      *
  728.      * @return Collection
  729.      */
  730.     public function getContent()
  731.     {
  732.         return $this->content;
  733.     }
  734.     /**
  735.      * @param $locale
  736.      * @return VehicleContent
  737.      */
  738.     public function getContentByLocale($locale)
  739.     {
  740.         foreach ($this->getContent() as $content) {
  741.             if($content->getLanguage() == $locale) {
  742.                 return $content;
  743.             }
  744.         }
  745.         return $this->getContent()->first();
  746.     }
  747.     /**
  748.      * Add equipment
  749.      *
  750.      * @param Equipment $equipment
  751.      *
  752.      * @return Vehicle
  753.      */
  754.     public function addEquipment(Equipment $equipment)
  755.     {
  756.         $this->equipments[] = $equipment;
  757.         return $this;
  758.     }
  759.     /**
  760.      * Remove equipment
  761.      *
  762.      * @param Equipment $equipment
  763.      */
  764.     public function removeEquipment(Equipment $equipment)
  765.     {
  766.         $this->equipments->removeElement($equipment);
  767.     }
  768.     /**
  769.      * Get equipments
  770.      *
  771.      * @return Collection
  772.      */
  773.     public function getEquipments()
  774.     {
  775.         return $this->equipments;
  776.     }
  777.     public function getArrayEquipments()
  778.     {
  779.         return $this->equipments->toArray();
  780.     }
  781.     /**
  782.      * Add feature
  783.      *
  784.      * @param Feature $feature
  785.      *
  786.      * @return Vehicle
  787.      */
  788.     public function addFeature(Feature $feature)
  789.     {
  790.         $this->features[] = $feature;
  791.         return $this;
  792.     }
  793.     /**
  794.      * Remove feature
  795.      *
  796.      * @param Feature $feature
  797.      */
  798.     public function removeFeature(Feature $feature)
  799.     {
  800.         $this->features->removeElement($feature);
  801.     }
  802.     /**
  803.      * Get features
  804.      *
  805.      * @return Collection
  806.      */
  807.     public function getFeatures()
  808.     {
  809.         return $this->features;
  810.     }
  811.     /**
  812.      * Add variation
  813.      *
  814.      * @param Variation $variation
  815.      *
  816.      * @return Vehicle
  817.      */
  818.     public function addVariation(Variation $variation)
  819.     {
  820.         $this->variations[] = $variation;
  821.         return $this;
  822.     }
  823.     /**
  824.      * Remove variation
  825.      *
  826.      * @param Variation $variation
  827.      */
  828.     public function removeVariation(Variation $variation)
  829.     {
  830.         $this->variations->removeElement($variation);
  831.     }
  832.     /**
  833.      * Get variations
  834.      *
  835.      * @return Collection
  836.      */
  837.     public function getVariations()
  838.     {
  839.         return $this->variations;
  840.     }
  841.     public function getArrayVariations()
  842.     {
  843.         return $this->variations->toArray();
  844.     }
  845.     /**
  846.      * Set creator
  847.      *
  848.      * @param User $creator
  849.      *
  850.      * @return Vehicle
  851.      */
  852.     public function setCreator(User $creator null)
  853.     {
  854.         $this->creator $creator;
  855.         return $this;
  856.     }
  857.     /**
  858.      * Get creator
  859.      *
  860.      * @return User
  861.      */
  862.     public function getCreator()
  863.     {
  864.         return $this->creator;
  865.     }
  866.     /**
  867.      * Set dealer
  868.      *
  869.      * @param Dealer $dealer
  870.      *
  871.      * @return Vehicle
  872.      */
  873.     public function setDealer(Dealer $dealer null)
  874.     {
  875.         $this->dealer $dealer;
  876.         return $this;
  877.     }
  878.     /**
  879.      * Get dealer
  880.      *
  881.      * @return Dealer
  882.      */
  883.     public function getDealer()
  884.     {
  885.         return $this->dealer;
  886.     }
  887.     /**
  888.      * Set model
  889.      *
  890.      * @param Model $model
  891.      *
  892.      * @return Vehicle
  893.      */
  894.     public function setModel(Model $model null)
  895.     {
  896.         $this->model $model;
  897.         return $this;
  898.     }
  899.     /**
  900.      * Get model
  901.      *
  902.      * @return Model
  903.      */
  904.     public function getModel()
  905.     {
  906.         return $this->model;
  907.     }
  908.     /**
  909.      * Set category
  910.      *
  911.      * @param Category $category
  912.      *
  913.      * @return Vehicle
  914.      */
  915.     public function setCategory(Category $category null)
  916.     {
  917.         $this->category $category;
  918.         return $this;
  919.     }
  920.     /**
  921.      * Get category
  922.      *
  923.      * @return Category
  924.      */
  925.     public function getCategory()
  926.     {
  927.         return $this->category;
  928.     }
  929.     /**
  930.      * Set group
  931.      *
  932.      * @param Group $group
  933.      *
  934.      * @return Vehicle
  935.      */
  936.     public function setGroup(Group $group null)
  937.     {
  938.         $this->group $group;
  939.         return $this;
  940.     }
  941.     /**
  942.      * Get group
  943.      *
  944.      * @return Group
  945.      */
  946.     public function getGroup()
  947.     {
  948.         return $this->group;
  949.     }
  950.     /**
  951.      * Add post
  952.      *
  953.      * @param Post $post
  954.      *
  955.      * @return Vehicle
  956.      */
  957.     public function addPost(Post $post)
  958.     {
  959.         $this->posts[] = $post;
  960.         return $this;
  961.     }
  962.     /**
  963.      * Remove post
  964.      *
  965.      * @param Post $post
  966.      */
  967.     public function removePost(Post $post)
  968.     {
  969.         $this->posts->removeElement($post);
  970.     }
  971.     /**
  972.      * Get posts
  973.      *
  974.      * @return Collection
  975.      */
  976.     public function getPosts()
  977.     {
  978.         return $this->posts;
  979.     }
  980.     /**
  981.      * Set adminName
  982.      *
  983.      * @param string $adminName
  984.      *
  985.      * @return Vehicle
  986.      */
  987.     public function setAdminName($adminName)
  988.     {
  989.         $this->admin_name $adminName;
  990.         return $this;
  991.     }
  992.     /**
  993.      * Get adminName
  994.      *
  995.      * @return string
  996.      */
  997.     public function getAdminName()
  998.     {
  999.         if($this->admin_name) {
  1000.             return  $this->admin_name;
  1001.         }
  1002.         if(!$this->getModel()) {
  1003.             return  '';
  1004.         }
  1005.         return $this->getModel()->getTitle();
  1006.     }
  1007.     public function __toString()
  1008.     {
  1009.         $name $this->getAdminName();
  1010.         if(!$this->getState()) {
  1011.             $name .= ' (не Ð°ÐºÑ‚ивна)';
  1012.         }
  1013.         return $name;
  1014.     }
  1015.     /**
  1016.      * Add color
  1017.      *
  1018.      * @param ConfiguratorColor $color
  1019.      *
  1020.      * @return Vehicle
  1021.      */
  1022.     public function addColor(ConfiguratorColor $color)
  1023.     {
  1024.         $this->colors[] = $color;
  1025.         return $this;
  1026.     }
  1027.     /**
  1028.      * Remove color
  1029.      *
  1030.      * @param ConfiguratorColor $color
  1031.      */
  1032.     public function removeColor(ConfiguratorColor $color)
  1033.     {
  1034.         $this->colors->removeElement($color);
  1035.     }
  1036.     /**
  1037.      * Get colors
  1038.      *
  1039.      * @return Collection
  1040.      */
  1041.     public function getColors()
  1042.     {
  1043.         return $this->colors;
  1044.     }
  1045.     /**
  1046.      * Add interier
  1047.      *
  1048.      * @param ConfiguratorInterier $interier
  1049.      *
  1050.      * @return Vehicle
  1051.      */
  1052.     public function addInterier(ConfiguratorInterier $interier)
  1053.     {
  1054.         $this->interiers[] = $interier;
  1055.         return $this;
  1056.     }
  1057.     /**
  1058.      * Remove interier
  1059.      *
  1060.      * @param ConfiguratorInterier $interier
  1061.      */
  1062.     public function removeInterier(ConfiguratorInterier $interier)
  1063.     {
  1064.         $this->interiers->removeElement($interier);
  1065.     }
  1066.     /**
  1067.      * Get interiers
  1068.      *
  1069.      * @return Collection
  1070.      */
  1071.     public function getInteriers()
  1072.     {
  1073.         return $this->interiers;
  1074.     }
  1075.     /**
  1076.      * Add vehicleItem
  1077.      *
  1078.      * @param VehicleItem $vehicleItem
  1079.      *
  1080.      * @return Vehicle
  1081.      */
  1082.     public function addVehicleItem(VehicleItem $vehicleItem)
  1083.     {
  1084.         $this->vehicle_items[] = $vehicleItem;
  1085.         return $this;
  1086.     }
  1087.     /**
  1088.      * Remove vehicleItem
  1089.      *
  1090.      * @param VehicleItem $vehicleItem
  1091.      */
  1092.     public function removeVehicleItem(VehicleItem $vehicleItem)
  1093.     {
  1094.         $this->vehicle_items->removeElement($vehicleItem);
  1095.     }
  1096.     /**
  1097.      * Get vehicleItems
  1098.      *
  1099.      * @return Collection
  1100.      */
  1101.     public function getVehicleItems()
  1102.     {
  1103.         return $this->vehicle_items;
  1104.     }
  1105.     public function getArrayVehicleItems()
  1106.     {
  1107.         return $this->vehicle_items->toArray();
  1108.     }
  1109.     /**
  1110.      * @var string
  1111.      */
  1112.     private $is_delete 0;
  1113.     /**
  1114.      * Set isDelete
  1115.      *
  1116.      * @param string $isDelete
  1117.      *
  1118.      * @return Vehicle
  1119.      */
  1120.     public function setIsDelete($isDelete)
  1121.     {
  1122.         $this->is_delete $isDelete;
  1123.         return $this;
  1124.     }
  1125.     /**
  1126.      * Get isDelete
  1127.      *
  1128.      * @return string
  1129.      */
  1130.     public function getIsDelete()
  1131.     {
  1132.         return $this->is_delete;
  1133.     }
  1134.     /**
  1135.      * @var string
  1136.      */
  1137.     private $card_js;
  1138.     /**
  1139.      * Set cardJs
  1140.      *
  1141.      * @param string $cardJs
  1142.      *
  1143.      * @return Vehicle
  1144.      */
  1145.     public function setCardJs($cardJs)
  1146.     {
  1147.         $this->card_js $cardJs;
  1148.         return $this;
  1149.     }
  1150.     /**
  1151.      * Get cardJs
  1152.      *
  1153.      * @return string
  1154.      */
  1155.     public function getCardJs()
  1156.     {
  1157.         return $this->card_js;
  1158.     }
  1159.     private $school_available 0;
  1160.     /**
  1161.      * Set schoolAvailable
  1162.      *
  1163.      * @param integer $schoolAvailable
  1164.      *
  1165.      * @return Vehicle
  1166.      */
  1167.     public function setSchoolAvailable($schoolAvailable)
  1168.     {
  1169.         $this->school_available $schoolAvailable;
  1170.         return $this;
  1171.     }
  1172.     /**
  1173.      * Get schoolAvailable
  1174.      *
  1175.      * @return integer
  1176.      */
  1177.     public function getSchoolAvailable()
  1178.     {
  1179.         return $this->school_available 0;
  1180.     }
  1181.     /**
  1182.      * @var string
  1183.      */
  1184.     private $ria_id;
  1185.     /**
  1186.      * Set riaId
  1187.      *
  1188.      * @param string $riaId
  1189.      *
  1190.      * @return Vehicle
  1191.      */
  1192.     public function setRiaId($riaId)
  1193.     {
  1194.         $this->ria_id $riaId;
  1195.         return $this;
  1196.     }
  1197.     /**
  1198.      * Get riaId
  1199.      *
  1200.      * @return string
  1201.      */
  1202.     public function getRiaId()
  1203.     {
  1204.         return $this->ria_id;
  1205.     }
  1206.     /**
  1207.      * @var Collection
  1208.      */
  1209.     private $recommend_group;
  1210.     /**
  1211.      * Add recommendGroup
  1212.      *
  1213.      * @param RecommendGroup $recommendGroup
  1214.      *
  1215.      * @return Vehicle
  1216.      */
  1217.     public function addRecommendGroup(RecommendGroup $recommendGroup)
  1218.     {
  1219.         $this->recommend_group[] = $recommendGroup;
  1220.         return $this;
  1221.     }
  1222.     /**
  1223.      * Remove recommendGroup
  1224.      *
  1225.      * @param RecommendGroup $recommendGroup
  1226.      */
  1227.     public function removeRecommendGroup(RecommendGroup $recommendGroup)
  1228.     {
  1229.         $this->recommend_group->removeElement($recommendGroup);
  1230.     }
  1231.     /**
  1232.      * Get recommendGroup
  1233.      *
  1234.      * @return Collection
  1235.      */
  1236.     public function getRecommendGroup()
  1237.     {
  1238.         return $this->recommend_group;
  1239.     }
  1240.     /**
  1241.      * @var string
  1242.      */
  1243.     private $ria_options;
  1244.     /**
  1245.      * Set riaOptions
  1246.      *
  1247.      * @param string $riaOptions
  1248.      *
  1249.      * @return Vehicle
  1250.      */
  1251.     public function setRiaOptions($riaOptions)
  1252.     {
  1253.         $this->ria_options $riaOptions;
  1254.         return $this;
  1255.     }
  1256.     /**
  1257.      * Get riaOptions
  1258.      *
  1259.      * @return string
  1260.      */
  1261.     public function getRiaOptions()
  1262.     {
  1263.         return $this->ria_options;
  1264.     }
  1265.     /**
  1266.      * Set crmId
  1267.      *
  1268.      * @param string $crmId
  1269.      *
  1270.      * @return Vehicle
  1271.      */
  1272.     public function setCrmId($crmId)
  1273.     {
  1274.         $this->crm_id $crmId;
  1275.         return $this;
  1276.     }
  1277.     /**
  1278.      * Get crmId
  1279.      *
  1280.      * @return string
  1281.      */
  1282.     public function getCrmId()
  1283.     {
  1284.         return $this->crm_id;
  1285.     }
  1286.     /**
  1287.      * @return int
  1288.      */
  1289.     public function getIsNotFilled()
  1290.     {
  1291.         return $this->is_not_filled;
  1292.     }
  1293.     /**
  1294.      * @param int $is_not_filled
  1295.      *
  1296.      * @return Vehicle
  1297.      */
  1298.     public function setIsNotFilled($is_not_filled)
  1299.     {
  1300.         $this->is_not_filled $is_not_filled;
  1301.         return $this;
  1302.     }
  1303.     /**
  1304.      * @return int
  1305.      */
  1306.     public function getRiaLevel()
  1307.     {
  1308.         return $this->ria_level;
  1309.     }
  1310.     /**
  1311.      * @param int $ria_level
  1312.      *
  1313.      * @return Vehicle
  1314.      */
  1315.     public function setRiaLevel($ria_level)
  1316.     {
  1317.         $this->ria_level $ria_level;
  1318.         return $this;
  1319.     }
  1320.     /**
  1321.      * @return int
  1322.      */
  1323.     public function getRiaPeriod()
  1324.     {
  1325.         return $this->ria_period;
  1326.     }
  1327.     /**
  1328.      * @param int $ria_period
  1329.      *
  1330.      * @return Vehicle
  1331.      */
  1332.     public function setRiaPeriod($ria_period)
  1333.     {
  1334.         $this->ria_period $ria_period;
  1335.         return $this;
  1336.     }
  1337.     /**
  1338.      * @var integer
  1339.      */
  1340.     private $views;
  1341.     /**
  1342.      * Set views
  1343.      *
  1344.      * @param integer $views
  1345.      *
  1346.      * @return Vehicle
  1347.      */
  1348.     public function setViews($views)
  1349.     {
  1350.         $this->views $views;
  1351.         return $this;
  1352.     }
  1353.     /**
  1354.      * Get views
  1355.      *
  1356.      * @return integer
  1357.      */
  1358.     public function getViews()
  1359.     {
  1360.         return $this->views;
  1361.     }
  1362.     /**
  1363.      * @return DateTime
  1364.      */
  1365.     public function getRiaPublicationDate()
  1366.     {
  1367.         return $this->ria_publication_date;
  1368.     }
  1369.     /**
  1370.      * @param DateTime $ria_publication_date
  1371.      *
  1372.      * @return Vehicle
  1373.      */
  1374.     public function setRiaPublicationDate($ria_publication_date)
  1375.     {
  1376.         $this->ria_publication_date $ria_publication_date;
  1377.         return $this;
  1378.     }
  1379.     /**
  1380.      * @return DateTime
  1381.      */
  1382.     public function getRiaTopPublicationDate()
  1383.     {
  1384.         return $this->ria_top_publication_date;
  1385.     }
  1386.     /**
  1387.      * @param DateTime $ria_top_publication_date
  1388.      *
  1389.      * @return Vehicle
  1390.      */
  1391.     public function setRiaTopPublicationDate($ria_top_publication_date)
  1392.     {
  1393.         $this->ria_top_publication_date $ria_top_publication_date;
  1394.         return $this;
  1395.     }
  1396.     /**
  1397.      * @return int
  1398.      */
  1399.     public function getRiaIsNotified()
  1400.     {
  1401.         return $this->ria_is_notified;
  1402.     }
  1403.     /**
  1404.      * @param int $ria_is_notified
  1405.      *
  1406.      * @return Vehicle
  1407.      */
  1408.     public function setRiaIsNotified($ria_is_notified)
  1409.     {
  1410.         $this->ria_is_notified $ria_is_notified;
  1411.         return $this;
  1412.     }
  1413.     public function getDays()
  1414.     {
  1415.         $days 1;
  1416.         if ($this->date_create) {
  1417.             $days = (new DateTime('now'))->diff($this->date_create)->days;
  1418.             $days $days $days;
  1419.         }
  1420.         return $days;
  1421.     }
  1422.     public function getAdminViews()
  1423.     {
  1424.         $perDays ceil($this->views $this->getDays()) ;
  1425.         return ((int) $this->views).' / '.$perDays;
  1426.     }
  1427.     /**
  1428.      * @var Collection
  1429.      */
  1430.     private $faqs;
  1431.     /**
  1432.      * Add faq
  1433.      *
  1434.      * @param Faq $faq
  1435.      *
  1436.      * @return Vehicle
  1437.      */
  1438.     public function addFaq(Faq $faq)
  1439.     {
  1440.         $this->faqs[] = $faq;
  1441.         return $this;
  1442.     }
  1443.     /**
  1444.      * Remove faq
  1445.      *
  1446.      * @param Faq $faq
  1447.      */
  1448.     public function removeFaq(Faq $faq)
  1449.     {
  1450.         $this->faqs->removeElement($faq);
  1451.     }
  1452.     /**
  1453.      * Get faq
  1454.      *
  1455.      * @return Collection
  1456.      */
  1457.     public function getFaqs()
  1458.     {
  1459.         return $this->faqs;
  1460.     }
  1461.     /**
  1462.      * Set isPreOrder
  1463.      *
  1464.      * @param integer $isPreOrder
  1465.      *
  1466.      * @return Vehicle
  1467.      */
  1468.     public function setIsPreOrder($isPreOrder)
  1469.     {
  1470.         $this->is_pre_order $isPreOrder;
  1471.         return $this;
  1472.     }
  1473.     /**
  1474.      * Get isPreOrder
  1475.      *
  1476.      * @return integer
  1477.      */
  1478.     public function getIsPreOrder()
  1479.     {
  1480.         return $this->is_pre_order 0;
  1481.     }
  1482.     /**
  1483.      * Add boatEngine
  1484.      *
  1485.      * @param \CoreBundle\Entity\Vehicles\Vehicle $boatEngine
  1486.      *
  1487.      * @return Vehicle
  1488.      */
  1489.     public function addBoatEngine(\CoreBundle\Entity\Vehicles\Vehicle $boatEngine)
  1490.     {
  1491.         $this->boat_engine[] = $boatEngine;
  1492.         return $this;
  1493.     }
  1494.     /**
  1495.      * Remove boatEngine
  1496.      *
  1497.      * @param \CoreBundle\Entity\Vehicles\Vehicle $boatEngine
  1498.      */
  1499.     public function removeBoatEngine(\CoreBundle\Entity\Vehicles\Vehicle $boatEngine)
  1500.     {
  1501.         $this->boat_engine->removeElement($boatEngine);
  1502.     }
  1503.     /**
  1504.      * Get boatEngine
  1505.      *
  1506.      * @return Collection
  1507.      */
  1508.     public function getBoatEngine()
  1509.     {
  1510.         return $this->boat_engine;
  1511.     }
  1512.     /**
  1513.      * @var boolean
  1514.      */
  1515.     private $noindex_follow false;
  1516.     /**
  1517.      * Set noindexFollow
  1518.      *
  1519.      * @param boolean $noindexFollow
  1520.      *
  1521.      * @return Vehicle
  1522.      */
  1523.     public function setNoindexFollow($noindexFollow)
  1524.     {
  1525.         $this->noindex_follow $noindexFollow;
  1526.         return $this;
  1527.     }
  1528.     /**
  1529.      * Get noindexFollow
  1530.      *
  1531.      * @return boolean
  1532.      */
  1533.     public function getNoindexFollow()
  1534.     {
  1535.         return $this->noindex_follow;
  1536.     }
  1537.     /**
  1538.      * @var Collection
  1539.      */
  1540.     private $categories;
  1541.     /**
  1542.      * Add category.
  1543.      *
  1544.      * @param Category $category
  1545.      *
  1546.      * @return Vehicle
  1547.      */
  1548.     public function addCategory(Category $category)
  1549.     {
  1550.         $this->categories[] = $category;
  1551.         return $this;
  1552.     }
  1553.     /**
  1554.      * Remove category.
  1555.      *
  1556.      * @param Category $category
  1557.      *
  1558.      * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  1559.      */
  1560.     public function removeCategory(Category $category)
  1561.     {
  1562.         return $this->categories->removeElement($category);
  1563.     }
  1564.     /**
  1565.      * Get categories.
  1566.      *
  1567.      * @return Collection
  1568.      */
  1569.     public function getCategories()
  1570.     {
  1571.         return $this->categories;
  1572.     }
  1573.     /**
  1574.      * Add autoRiaOption.
  1575.      *
  1576.      * @param AutoRiaOptions $autoRiaOption
  1577.      * @param bool $isShow
  1578.      * @return Vehicle
  1579.      */
  1580.     public function addAutoRiaOption(AutoRiaOptions $autoRiaOptionbool $isShow true): self
  1581.     {
  1582.         foreach ($this->vehicle_auto_ria_options as $relation) {
  1583.             if ($relation->getOption() === $autoRiaOption) {
  1584.                 $relation->setIsShowInPdf($isShow);
  1585.                 return $this;
  1586.             }
  1587.         }
  1588.         $relation = new VehicleAutoRiaOption();
  1589.         $relation->setVehicle($this);
  1590.         $relation->setOption($autoRiaOption);
  1591.         $relation->setIsShowInPdf($isShow);
  1592.         $this->vehicle_auto_ria_options[] = $relation;
  1593.         return $this;
  1594.     }
  1595.     /**
  1596.      * Remove autoRiaOption.
  1597.      *
  1598.      * @param AutoRiaOptions $autoRiaOption
  1599.      *
  1600.      * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  1601.      */
  1602.     public function removeAutoRiaOption(AutoRiaOptions $autoRiaOption): bool
  1603.     {
  1604.         foreach ($this->vehicle_auto_ria_options as $key => $relation) {
  1605.             if ($relation->getOption() === $autoRiaOption) {
  1606.                 $this->vehicle_auto_ria_options->remove($key);
  1607.                 return true;
  1608.             }
  1609.         }
  1610.         return false;
  1611.     }
  1612.     /**
  1613.      * Get autoRiaOption.
  1614.      *
  1615.      * @return Collection
  1616.      */
  1617.     public function getAutoRiaOptions(): Collection
  1618.     {
  1619.         if (is_null($this->vehicle_auto_ria_options)) {
  1620.             return new ArrayCollection();
  1621.         }
  1622.         return $this->vehicle_auto_ria_options->map(function(VehicleAutoRiaOption $relation) {
  1623.             return $relation->getOption();
  1624.         });
  1625.     }
  1626.     /**
  1627.      * @return Collection|VehicleAutoRiaOption[]
  1628.      */
  1629.     public function getVehicleAutoRiaOptions(): ?Collection
  1630.     {
  1631.         if (is_null($this->vehicle_auto_ria_options)){
  1632.             return new ArrayCollection();
  1633.         }
  1634.         return $this->vehicle_auto_ria_options;
  1635.     }
  1636.     public function addVehicleAutoRiaOption(VehicleAutoRiaOption $option)
  1637.     {
  1638.         if (!$this->vehicle_auto_ria_options->contains($option)) {
  1639.             $option->setVehicle($this);
  1640.             $this->vehicle_auto_ria_options[] = $option;
  1641.         }
  1642.     }
  1643.     public function removeVehicleAutoRiaOption(VehicleAutoRiaOption $option)
  1644.     {
  1645.         if ($this->vehicle_auto_ria_options->contains($option)) {
  1646.             $this->vehicle_auto_ria_options->removeElement($option);
  1647.             $option->setVehicle(null);
  1648.         }
  1649.     }
  1650.     public function setVehicleCardType(?VehicleCardType $vehicleCardType): Vehicle
  1651.     {
  1652.         $this->vehicleCardType $vehicleCardType;
  1653.         if ($vehicleCardType !== null) {
  1654.             $vehicleCardType->setVehicle($this);
  1655.         }
  1656.         return $this;
  1657.     }
  1658.     public function getVehicleCardType(): ?VehicleCardType
  1659.     {
  1660.         return $this->vehicleCardType;
  1661.     }
  1662.     public function getUpdatedAt(): DateTime
  1663.     {
  1664.         return $this->updatedAt;
  1665.     }
  1666.     public function setUpdatedAt(): self
  1667.     {
  1668.         $this->updatedAt = new \DateTime();
  1669.         return $this;
  1670.     }
  1671. }