<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Atrybuty
*
* @ORM\Table(name="atrybuty")
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\AtrybutyRepository")
*/
class Atrybuty
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nazwa", type="string", length=255, nullable=false)
*/
private $nazwa;
/**
* @var string|null
*
* @ORM\Column(name="opis", type="string", length=255, nullable=true)
*/
private $opis;
/**
* @var int
*
* @ORM\Column(name="id_grupy", type="integer", nullable=false)
*/
private $idGrupy;
/**
* @var int|null
*
* @ORM\Column(name="typ", type="integer", nullable=true)
*/
private $typ;
/**
* @var string|null
*
* @ORM\Column(name="cena", type="decimal", precision=10, scale=0, nullable=true)
*/
private $cena;
/**
* @var bool|null
*
* @ORM\Column(name="widoczny", type="boolean", nullable=true)
*/
private $widoczny;
/**
* @var bool|null
*
* @ORM\Column(name="stala_cena", type="boolean", nullable=true)
*/
private $stalaCena;
/**
* @var int
*
* @ORM\Column(name="kolejnosc", type="smallint", nullable=false)
*/
private $kolejnosc;
/**
* @var string|null
*
* @ORM\Column(name="path", type="string", length=255, nullable=true)
*/
//private $path;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nazwa
*
* @param string $nazwa
*
* @return AtrybutyProdukt
*/
public function setNazwa($nazwa)
{
$this->nazwa = $nazwa;
return $this;
}
/**
* Get nazwa
*
* @return string
*/
public function getNazwa()
{
return $this->nazwa;
}
/**
* Set opis
*
* @param string $opis
*
* @return AtrybutyProdukt
*/
public function setOpis($opis)
{
$this->opis = $opis;
return $this;
}
/**
* Get opis
*
* @return string
*/
public function getOpis()
{
return $this->opis;
}
/**
* Set idGrupy
*
* @param integer $idGrupy
*
* @return AtrybutyProdukt
*/
public function setIdGrupy($idGrupy)
{
$this->idGrupy = $idGrupy;
return $this;
}
/**
* Get idGrupy
*
* @return integer
*/
public function getIdGrupy()
{
return $this->idGrupy;
}
/**
* Set typ
*
* @param string $typ
*
* @return AtrybutyProdukt
*/
public function setTyp($typ)
{
$this->typ = $typ;
return $this;
}
/**
* Get typ
*
* @return string
*/
public function getTyp()
{
return $this->typ;
}
/**
* Set cena
*
* @param string $cena
*
* @return AtrybutyProdukt
*/
public function setCena($cena)
{
$this->cena = $cena;
return $this;
}
/**
* Get cena
*
* @return string
*/
public function getCena()
{
return $this->cena;
}
/**
* Set widoczny
*
* @param boolean $widoczny
*
* @return AtrybutyProdukt
*/
public function setWidoczny($widoczny)
{
$this->widoczny = $widoczny;
return $this;
}
/**
* Get widoczny
*
* @return boolean
*/
public function getWidoczny()
{
return $this->widoczny;
}
/**
* Set stalaCena
*
* @param boolean $stalaCena
*
* @return AtrybutyProdukt
*/
public function setStalaCena($stalaCena)
{
$this->stalaCena = $stalaCena;
return $this;
}
/**
* Get stalaCena
*
* @return boolean
*/
public function getStalaCena()
{
return $this->stalaCena;
}
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $path;
public function getAbsolutePath()
{
return null === $this->path
? null
: $this->getUploadRootDir().'/'.$this->path;
}
public function getWebPath()
{
return null === $this->path
? null
: $this->getUploadDir().'/'.$this->path;
}
protected function getUploadRootDir()
{
// the absolute directory path where uploaded
// documents should be saved
return __DIR__.'/../../public/'.$this->getUploadDir();
}
protected function getUploadDir()
{
// get rid of the __DIR__ so it doesn't screw up
// when displaying uploaded doc/image in the view.
return 'uploads/parametry';
}
/**
* @Assert\File(maxSize="6000000")
*/
private $file;
/**
* Sets file.
*
* @param UploadedFile $file
*/
public function setFile(UploadedFile $file = null)
{
$this->file = $file;
}
/**
* Get file.
*
* @return UploadedFile
*/
public function getFile()
{
return $this->file;
}
public function upload()
{
// the file property can be empty if the field is not required
if (null === $this->getFile()) {
return;
}
// use the original file name here but you should
// sanitize it at least to avoid any security issues
$name = 'image_' . date('Y-m-d-H-i-s') . '_' . uniqid() .'.'.$this->getFile()->guessExtension();
// move takes the target directory and then the
// target filename to move to
$this->getFile()->move(
$this->getUploadRootDir(),
$name
);
// set the path property to the filename where you've saved the file
$this->path = $name;
// clean up the file property as you won't need it anymore
$this->file = null;
}
/**
* Set path
*
* @param string $path
*
* @return Atrybuty
*/
public function setPath($path)
{
$this->path = $path;
return $this;
}
/**
* Get path
*
* @return string
*/
public function getPath()
{
return $this->path;
}
/**
* Set kolejnosc
*
* @param integer $kolejnosc
*
* @return Atrybuty
*/
public function setKolejnosc($kolejnosc)
{
$this->kolejnosc = $kolejnosc;
return $this;
}
/**
* Get kolejnosc
*
* @return integer
*/
public function getKolejnosc()
{
return $this->kolejnosc;
}
}