src/Entity/Produit/Service/Message.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Produit\Service;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Validator\Validatortext\Email;
  5. use App\Validator\Validatortext\Taillemin;
  6. use App\Validator\Validatortext\Taillemax;
  7. use App\Repository\Produit\Service\MessageRepository;
  8. use App\Entity\Users\User\User;
  9. /**
  10.  * Message
  11.  *
  12.  * @ORM\Table("message")
  13.  * @ORM\Entity(repositoryClass=MessageRepository::class)
  14.  */
  15. class Message
  16. {
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="titre", type="string", length=255,nullable=true)
  29.      *@Taillemin(valeur=3, message="Au moins 3 caractères")
  30.      *@Taillemax(valeur=250, message="Au plus 250 caractès")
  31.      */
  32.     private $titre;
  33.     
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(name="nom", type="string", length=255,nullable=true)
  38.      *@Taillemax(valeur=100, message="Au plus 100 caractès")
  39.      */
  40.     private $nom;
  41.     
  42.     /**
  43.      * @var integer
  44.      *
  45.      * @ORM\Column(name="tel", type="integer", nullable=true)
  46.      */
  47.     private $tel;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @ORM\Column(name="contenu", type="text")
  52.      *@Taillemax(valeur=300, message="Au plus 300 caractès")
  53.      */
  54.     private $contenu;
  55.     
  56.     /**
  57.      * @var integer
  58.      *
  59.      * @ORM\Column(name="timestamp", type="bigint")
  60.      */
  61.     private $timestamp;
  62.     
  63.     /**
  64.      * @var boolean
  65.      *
  66.      * @ORM\Column(name="valide", type="boolean")
  67.      */
  68.     private $valide;
  69.     
  70.     /**
  71.      * @var boolean
  72.      *
  73.      * @ORM\Column(name="lut", type="boolean")
  74.      */
  75.     private $lut;
  76.     /**
  77.      * @var \DateTime
  78.      *
  79.      * @ORM\Column(name="date", type="datetime")
  80.      */
  81.     private $date;
  82.     /**
  83.      * @var string
  84.      *
  85.      *@ORM\Column(name="email", type="string", length=255,nullable=true)
  86.      *@Email()
  87.      */
  88.     private $email;
  89.     
  90.     /**
  91.       * @ORM\ManyToOne(targetEntity=User::class)
  92.       * @ORM\JoinColumn(nullable=true)
  93.     */
  94.     private $user;
  95.     
  96.     public function __construct()
  97.     {
  98.         $this->date = new \Datetime();
  99.         $this->timestamp time();
  100.         $this->valide false;
  101.         $this->lut false;
  102.     }
  103.     /**
  104.      * Get id
  105.      *
  106.      * @return integer 
  107.      */
  108.     public function getId()
  109.     {
  110.         return $this->id;
  111.     }
  112.     /**
  113.      * Set titre
  114.      *
  115.      * @param string $titre
  116.      * @return Message
  117.      */
  118.     public function setTitre($titre)
  119.     {
  120.         $this->titre $titre;
  121.         return $this;
  122.     }
  123.     /**
  124.      * Get titre
  125.      *
  126.      * @return string 
  127.      */
  128.     public function getTitre()
  129.     {
  130.         return $this->titre;
  131.     }
  132.     /**
  133.      * Set contenu
  134.      *
  135.      * @param string $contenu
  136.      * @return Message
  137.      */
  138.     public function setContenu($contenu)
  139.     {
  140.         $this->contenu $contenu;
  141.         return $this;
  142.     }
  143.     /**
  144.      * Get contenu
  145.      *
  146.      * @return string 
  147.      */
  148.     public function getContenu()
  149.     {
  150.         return $this->contenu;
  151.     }
  152.     /**
  153.      * Set date
  154.      *
  155.      * @param \DateTime $date
  156.      * @return Message
  157.      */
  158.     public function setDate($date)
  159.     {
  160.         $this->date $date;
  161.         return $this;
  162.     }
  163.     /**
  164.      * Get date
  165.      *
  166.      * @return \DateTime 
  167.      */
  168.     public function getDate()
  169.     {
  170.         return $this->date;
  171.     }
  172.     /**
  173.      * Set email
  174.      *
  175.      * @param string $email
  176.      * @return Message
  177.      */
  178.     public function setEmail($email)
  179.     {
  180.         $this->email $email;
  181.         return $this;
  182.     }
  183.     /**
  184.      * Get email
  185.      *
  186.      * @return string 
  187.      */
  188.     public function getEmail()
  189.     {
  190.         return $this->email;
  191.     }
  192.     /**
  193.      * Set nom
  194.      *
  195.      * @param string $nom
  196.      * @return Message
  197.      */
  198.     public function setNom($nom)
  199.     {
  200.         $this->nom $nom;
  201.         return $this;
  202.     }
  203.     /**
  204.      * Get nom
  205.      *
  206.      * @return string 
  207.      */
  208.     public function getNom()
  209.     {
  210.         return $this->nom;
  211.     }
  212.     /**
  213.      * Set user
  214.      * @return Message
  215.      */
  216.     public function setUser(User $user null): self
  217.     {
  218.         $this->user $user;
  219.         return $this;
  220.     }
  221.     /**
  222.      * Get user
  223.      */
  224.     public function getUser(): ?User
  225.     {
  226.         return $this->user;
  227.     }
  228.     
  229.     public function getDuree()
  230.     {
  231.     $seconde time() - $this->timestamp;
  232.     $minute round($seconde/60);
  233.     if($minute 60)
  234.     {
  235.        if($minute 3)
  236.        {
  237.            $duree 'à l\'instant';
  238.        }else{
  239.            $duree $minute.' min';
  240.        }
  241.     }else{
  242.        if($minute 60*24)
  243.        {
  244.        $duree = (floor(($minute/60))).'h'.($minute%60).'min';
  245.        }else{
  246.           if($minute 60*24*30)
  247.           {
  248.           $reste $minute - (floor($minute/(60*24)))*(60*24);
  249.           $duree = (floor($minute/(60*24))).'j'.(floor($reste/60)).'h';
  250.           }else{
  251.           $nbjour $this->date->diff(new \Datetime())->days;
  252.           $age floor($nbjour/365);
  253.           if($age 1)
  254.           {
  255.               $reste $nbjour - (floor($nbjour/(30)))*(30);
  256.               if(floor($nbjour/(30)) != 0)
  257.               {
  258.                   $duree = (floor($nbjour/(30))).'Mois'.($reste - (floor($reste/30)*30)).'J';
  259.               }else{
  260.                   $duree = ($reste - (floor($reste/30)*30)).'J';
  261.               }
  262.               
  263.           }else{
  264.               $courantyear date('Y');
  265.               $duree $courantyear $age
  266.           }
  267.           }
  268.        }
  269.     }
  270.     return $duree;
  271.     }
  272.     /**
  273.      * Set timestamp
  274.      *
  275.      * @param integer $timestamp
  276.      * @return Message
  277.      */
  278.     public function setTimestamp($timestamp)
  279.     {
  280.         $this->timestamp $timestamp;
  281.         return $this;
  282.     }
  283.     /**
  284.      * Get timestamp
  285.      *
  286.      * @return integer 
  287.      */
  288.     public function getTimestamp()
  289.     {
  290.         return $this->timestamp;
  291.     }
  292.     /**
  293.      * Set valide
  294.      *
  295.      * @param boolean $valide
  296.      * @return Message
  297.      */
  298.     public function setValide($valide)
  299.     {
  300.         $this->valide $valide;
  301.         return $this;
  302.     }
  303.     /**
  304.      * Get valide
  305.      *
  306.      * @return boolean 
  307.      */
  308.     public function getValide()
  309.     {
  310.         return $this->valide;
  311.     }
  312.     /**
  313.      * Set lut
  314.      *
  315.      * @param boolean $lut
  316.      * @return Message
  317.      */
  318.     public function setLut($lut)
  319.     {
  320.         $this->lut $lut;
  321.         return $this;
  322.     }
  323.     /**
  324.      * Get lut
  325.      *
  326.      * @return boolean 
  327.      */
  328.     public function getLut()
  329.     {
  330.         return $this->lut;
  331.     }
  332.     
  333.     /**
  334.      * Set tel
  335.      *
  336.      * @param integer $tel
  337.      * @return Message
  338.      */
  339.     public function setTel($tel)
  340.     {
  341.         $this->tel $tel;
  342.         return $this;
  343.     }
  344.     /**
  345.      * Get tel
  346.      *
  347.      * @return integer 
  348.      */
  349.     public function getTel()
  350.     {
  351.         return $this->tel;
  352.     }
  353. }