src/Entity/Atrybuty.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Component\HttpFoundation\File\UploadedFile;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. /**
  8.  * Atrybuty
  9.  *
  10.  * @ORM\Table(name="atrybuty")
  11.  * @ORM\Entity
  12.  * @ORM\Entity(repositoryClass="App\Repository\AtrybutyRepository")
  13.  */
  14. class Atrybuty
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer", nullable=false)
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="IDENTITY")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="nazwa", type="string", length=255, nullable=false)
  28.      */
  29.     private $nazwa;
  30.     /**
  31.      * @var string|null
  32.      *
  33.      * @ORM\Column(name="opis", type="string", length=255, nullable=true)
  34.      */
  35.     private $opis;
  36.     /**
  37.      * @var int
  38.      *
  39.      * @ORM\Column(name="id_grupy", type="integer", nullable=false)
  40.      */
  41.     private $idGrupy;
  42.     /**
  43.      * @var int|null
  44.      *
  45.      * @ORM\Column(name="typ", type="integer", nullable=true)
  46.      */
  47.     private $typ;
  48.     /**
  49.      * @var string|null
  50.      *
  51.      * @ORM\Column(name="cena", type="decimal", precision=10, scale=0, nullable=true)
  52.      */
  53.     private $cena;
  54.     /**
  55.      * @var bool|null
  56.      *
  57.      * @ORM\Column(name="widoczny", type="boolean", nullable=true)
  58.      */
  59.     private $widoczny;
  60.     /**
  61.      * @var bool|null
  62.      *
  63.      * @ORM\Column(name="stala_cena", type="boolean", nullable=true)
  64.      */
  65.     private $stalaCena;
  66.     /**
  67.      * @var int
  68.      *
  69.      * @ORM\Column(name="kolejnosc", type="smallint", nullable=false)
  70.      */
  71.     private $kolejnosc;
  72.     /**
  73.      * @var string|null
  74.      *
  75.      * @ORM\Column(name="path", type="string", length=255, nullable=true)
  76.      */
  77.     //private $path;
  78.   /**
  79.      * Get id
  80.      *
  81.      * @return integer
  82.      */
  83.     public function getId()
  84.     {
  85.         return $this->id;
  86.     }
  87.     /**
  88.      * Set nazwa
  89.      *
  90.      * @param string $nazwa
  91.      *
  92.      * @return AtrybutyProdukt
  93.      */
  94.     public function setNazwa($nazwa)
  95.     {
  96.         $this->nazwa $nazwa;
  97.         return $this;
  98.     }
  99.     /**
  100.      * Get nazwa
  101.      *
  102.      * @return string
  103.      */
  104.     public function getNazwa()
  105.     {
  106.         return $this->nazwa;
  107.     }
  108.     /**
  109.      * Set opis
  110.      *
  111.      * @param string $opis
  112.      *
  113.      * @return AtrybutyProdukt
  114.      */
  115.     public function setOpis($opis)
  116.     {
  117.         $this->opis $opis;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get opis
  122.      *
  123.      * @return string
  124.      */
  125.     public function getOpis()
  126.     {
  127.         return $this->opis;
  128.     }
  129.     /**
  130.      * Set idGrupy
  131.      *
  132.      * @param integer $idGrupy
  133.      *
  134.      * @return AtrybutyProdukt
  135.      */
  136.     public function setIdGrupy($idGrupy)
  137.     {
  138.         $this->idGrupy $idGrupy;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Get idGrupy
  143.      *
  144.      * @return integer
  145.      */
  146.     public function getIdGrupy()
  147.     {
  148.         return $this->idGrupy;
  149.     }
  150.     /**
  151.      * Set typ
  152.      *
  153.      * @param string $typ
  154.      *
  155.      * @return AtrybutyProdukt
  156.      */
  157.     public function setTyp($typ)
  158.     {
  159.         $this->typ $typ;
  160.         return $this;
  161.     }
  162.     /**
  163.      * Get typ
  164.      *
  165.      * @return string
  166.      */
  167.     public function getTyp()
  168.     {
  169.         return $this->typ;
  170.     }
  171.     /**
  172.      * Set cena
  173.      *
  174.      * @param string $cena
  175.      *
  176.      * @return AtrybutyProdukt
  177.      */
  178.     public function setCena($cena)
  179.     {
  180.         $this->cena $cena;
  181.         return $this;
  182.     }
  183.     /**
  184.      * Get cena
  185.      *
  186.      * @return string
  187.      */
  188.     public function getCena()
  189.     {
  190.         return $this->cena;
  191.     }
  192.     /**
  193.      * Set widoczny
  194.      *
  195.      * @param boolean $widoczny
  196.      *
  197.      * @return AtrybutyProdukt
  198.      */
  199.     public function setWidoczny($widoczny)
  200.     {
  201.         $this->widoczny $widoczny;
  202.         return $this;
  203.     }
  204.     /**
  205.      * Get widoczny
  206.      *
  207.      * @return boolean
  208.      */
  209.     public function getWidoczny()
  210.     {
  211.         return $this->widoczny;
  212.     }
  213.     /**
  214.      * Set stalaCena
  215.      *
  216.      * @param boolean $stalaCena
  217.      *
  218.      * @return AtrybutyProdukt
  219.      */
  220.     public function setStalaCena($stalaCena)
  221.     {
  222.         $this->stalaCena $stalaCena;
  223.         return $this;
  224.     }
  225.     /**
  226.      * Get stalaCena
  227.      *
  228.      * @return boolean
  229.      */
  230.     public function getStalaCena()
  231.     {
  232.         return $this->stalaCena;
  233.     }
  234.     /**
  235.      * @ORM\Column(type="string", length=255, nullable=true)
  236.      */
  237.     public $path;
  238.     public function getAbsolutePath()
  239.     {
  240.         return null === $this->path
  241.             null
  242.             $this->getUploadRootDir().'/'.$this->path;
  243.     }
  244.     public function getWebPath()
  245.     {
  246.         return null === $this->path
  247.             null
  248.             $this->getUploadDir().'/'.$this->path;
  249.     }
  250.     protected function getUploadRootDir()
  251.     {
  252.         // the absolute directory path where uploaded
  253.         // documents should be saved
  254.         return __DIR__.'/../../public/'.$this->getUploadDir();
  255.     }
  256.     protected function getUploadDir()
  257.     {
  258.         // get rid of the __DIR__ so it doesn't screw up
  259.         // when displaying uploaded doc/image in the view.
  260.         return 'uploads/parametry';
  261.     }
  262.     /**
  263.      * @Assert\File(maxSize="6000000")
  264.      */
  265.     private $file;
  266.     /**
  267.      * Sets file.
  268.      *
  269.      * @param UploadedFile $file
  270.      */
  271.     public function setFile(UploadedFile $file null)
  272.     {
  273.         $this->file $file;
  274.     }
  275.     /**
  276.      * Get file.
  277.      *
  278.      * @return UploadedFile
  279.      */
  280.     public function getFile()
  281.     {
  282.         return $this->file;
  283.     }
  284.     public function upload()
  285. {
  286.     // the file property can be empty if the field is not required
  287.     if (null === $this->getFile()) {
  288.         return;
  289.     }
  290.     // use the original file name here but you should
  291.     // sanitize it at least to avoid any security issues
  292.     $name 'image_' date('Y-m-d-H-i-s') . '_' uniqid() .'.'.$this->getFile()->guessExtension();
  293.     // move takes the target directory and then the
  294.     // target filename to move to
  295.     $this->getFile()->move(
  296.         $this->getUploadRootDir(),
  297.         $name
  298.     );
  299.     // set the path property to the filename where you've saved the file
  300.     $this->path $name;
  301.     // clean up the file property as you won't need it anymore
  302.     $this->file null;
  303. }
  304.     /**
  305.      * Set path
  306.      *
  307.      * @param string $path
  308.      *
  309.      * @return Atrybuty
  310.      */
  311.     public function setPath($path)
  312.     {
  313.         $this->path $path;
  314.         return $this;
  315.     }
  316.     /**
  317.      * Get path
  318.      *
  319.      * @return string
  320.      */
  321.     public function getPath()
  322.     {
  323.         return $this->path;
  324.     }
  325.     /**
  326.      * Set kolejnosc
  327.      *
  328.      * @param integer $kolejnosc
  329.      *
  330.      * @return Atrybuty
  331.      */
  332.     public function setKolejnosc($kolejnosc)
  333.     {
  334.         $this->kolejnosc $kolejnosc;
  335.         return $this;
  336.     }
  337.     /**
  338.      * Get kolejnosc
  339.      *
  340.      * @return integer
  341.      */
  342.     public function getKolejnosc()
  343.     {
  344.         return $this->kolejnosc;
  345.     }
  346. }