src/Entity/Information.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\InformationRepository;
  5. use App\Repository\UserRepository;
  6. use App\Traits\Actions;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassInformationRepository::class)]
  9. #[ORM\Table(name'hs_tc_information')]
  10. #[ApiResource]
  11. class Information
  12. {
  13.     use Actions;
  14.     #[ORM\Column(name"name"type"string"length255)]
  15.     private string $name;
  16.     #[ORM\Column(name"slug"type"string"length255)]
  17.     private string $slug;
  18.     #[ORM\Column(name"type"type"string"length255)]
  19.     private string $type;
  20.     #[ORM\Column(name"val"type"string"length255nullabletrue)]
  21.     private ?string $val null;
  22.     #[ORM\Column(name"category"type"string"length255nullabletrue)]
  23.     private ?string $category null;
  24.     #[ORM\Column(name"show_in_home"type"boolean")]
  25.     private bool $showInHome false;
  26.     #[ORM\Column(name"show_in_contact"type"boolean")]
  27.     private bool $showInContact false;
  28.     public function __construct()
  29.     {
  30.         // date_default_timezone_set('Africa/Casablanca');
  31.         $this->createAt = new \DateTime('now');
  32.         $this->published true;
  33.     }
  34.     public function setName(string $name): self
  35.     {
  36.         $this->name $name;
  37.         return $this;
  38.     }
  39.     public function getName(): string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function getSlug(): string
  44.     {
  45.         return $this->slug;
  46.     }
  47.     public function setSlug(string $slug): self
  48.     {
  49.         $this->slug $slug;
  50.         return $this;
  51.     }
  52.     public function getType(): string
  53.     {
  54.         return $this->type;
  55.     }
  56.     public function setType(string $type): self
  57.     {
  58.         $this->type $type;
  59.         return $this;
  60.     }
  61.     public function getVal(): ?string
  62.     {
  63.         return $this->val;
  64.     }
  65.     public function setVal(?string $val): self
  66.     {
  67.         $this->val $val;
  68.         return $this;
  69.     }
  70.     public function getCategory(): ?string
  71.     {
  72.         return $this->category;
  73.     }
  74.     public function setCategory(?string $category): self
  75.     {
  76.         $this->category $category;
  77.         return $this;
  78.     }
  79.     public function isShowInHome(): bool
  80.     {
  81.         return $this->showInHome;
  82.     }
  83.     public function setShowInHome(bool $showInHome): self
  84.     {
  85.         $this->showInHome $showInHome;
  86.         return $this;
  87.     }
  88.     public function isShowInContact(): bool
  89.     {
  90.         return $this->showInContact;
  91.     }
  92.     public function setShowInContact(bool $showInContact): self
  93.     {
  94.         $this->showInContact $showInContact;
  95.         return $this;
  96.     }
  97.     // Autres méthodes...
  98.     public function getNextNumber(){
  99.         if($this->val==null){
  100.             return 1;
  101.         }
  102.         return preg_replace_callback('/(\d+)\/(\d+)/', function ($matches) {
  103.             $numberBeforeSlash intval($matches[1]); // Convertit la chaîne en nombre entier
  104.             $numberBeforeSlash++; // Incrémente le nombre
  105.             return $numberBeforeSlash '/' $matches[2]; // Retourne la chaîne mise à jour
  106.         }, $this->val);
  107.     }
  108.     
  109. }