initial commit
This commit is contained in:
207
src/Entity/Kampagne.php
Normal file
207
src/Entity/Kampagne.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
namespace Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'kampagnen')]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Kampagne
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'boolean')]
|
||||
private bool $is_fb = false;
|
||||
|
||||
#[ORM\Column(type: 'boolean')]
|
||||
private bool $is_tr = false;
|
||||
|
||||
#[ORM\Column(type: 'boolean')]
|
||||
private bool $is_mail = false;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private string $dest_url;
|
||||
|
||||
#[ORM\Column(type: 'text', nullable: true)]
|
||||
private ?string $mailtext = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||
private ?string $img = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||
private ?string $linktext = null;
|
||||
|
||||
#[ORM\Column(type: 'smallint')]
|
||||
private int $ma = 0;
|
||||
|
||||
#[ORM\Column(type: 'smallint')]
|
||||
private int $reload = 0;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Werbenetzwerk::class)]
|
||||
#[ORM\JoinColumn(name: 'werbenetzwerk_id', referencedColumnName: 'werbenetzwerk', nullable: true)]
|
||||
private ?Werbenetzwerk $werbenetzwerk = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true)]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(type: 'datetime')]
|
||||
private \DateTimeInterface $dateCreated;
|
||||
|
||||
#[ORM\Column(type: 'datetime')]
|
||||
private \DateTimeInterface $dateModified;
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setDateCreatedValue(): void
|
||||
{
|
||||
$this->dateCreated = new \DateTime();
|
||||
$this->dateModified = new \DateTime();
|
||||
}
|
||||
|
||||
#[ORM\PreUpdate]
|
||||
public function setDateModifiedValue(): void
|
||||
{
|
||||
$this->dateModified = new \DateTime();
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIsFb(): bool
|
||||
{
|
||||
return $this->is_fb;
|
||||
}
|
||||
|
||||
public function setIsFb(bool $is_fb): self
|
||||
{
|
||||
$this->is_fb = $is_fb;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsTr(): bool
|
||||
{
|
||||
return $this->is_tr;
|
||||
}
|
||||
|
||||
public function setIsTr(bool $is_tr): self
|
||||
{
|
||||
$this->is_tr = $is_tr;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsMail(): bool
|
||||
{
|
||||
return $this->is_mail;
|
||||
}
|
||||
|
||||
public function setIsMail(bool $is_mail): self
|
||||
{
|
||||
$this->is_mail = $is_mail;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDestUrl(): string
|
||||
{
|
||||
return $this->dest_url;
|
||||
}
|
||||
|
||||
public function setDestUrl(string $dest_url): self
|
||||
{
|
||||
$this->dest_url = $dest_url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMailtext(): ?string
|
||||
{
|
||||
return $this->mailtext;
|
||||
}
|
||||
|
||||
public function setMailtext(?string $mailtext): self
|
||||
{
|
||||
$this->mailtext = $mailtext;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getImg(): ?string
|
||||
{
|
||||
return $this->img;
|
||||
}
|
||||
|
||||
public function setImg(?string $img): self
|
||||
{
|
||||
$this->img = $img;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLinktext(): ?string
|
||||
{
|
||||
return $this->linktext;
|
||||
}
|
||||
|
||||
public function setLinktext(?string $linktext): self
|
||||
{
|
||||
$this->linktext = $linktext;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMa(): int
|
||||
{
|
||||
return $this->ma;
|
||||
}
|
||||
|
||||
public function setMa(int $ma): self
|
||||
{
|
||||
$this->ma = $ma;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReload(): int
|
||||
{
|
||||
return $this->reload;
|
||||
}
|
||||
|
||||
public function setReload(int $reload): self
|
||||
{
|
||||
$this->reload = $reload;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateCreated(): \DateTimeInterface
|
||||
{
|
||||
return $this->dateCreated;
|
||||
}
|
||||
|
||||
public function getDateModified(): \DateTimeInterface
|
||||
{
|
||||
return $this->dateModified;
|
||||
}
|
||||
|
||||
public function getWerbenetzwerk(): ?Werbenetzwerk
|
||||
{
|
||||
return $this->werbenetzwerk;
|
||||
}
|
||||
|
||||
public function setWerbenetzwerk(?Werbenetzwerk $werbenetzwerk): self
|
||||
{
|
||||
$this->werbenetzwerk = $werbenetzwerk;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
82
src/Entity/User.php
Normal file
82
src/Entity/User.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: 'Repository\UserRepository')]
|
||||
#[ORM\Table(name: 'users')]
|
||||
class User
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private int $id;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 100)]
|
||||
private string $username;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private string $email;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 255)]
|
||||
private string $password;
|
||||
|
||||
#[ORM\Column(type: 'datetime')]
|
||||
private \DateTime $createdAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
// Getter und Setter
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function setUsername(string $username): self
|
||||
{
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): self
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTime $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
84
src/Entity/Werbenetzwerk.php
Normal file
84
src/Entity/Werbenetzwerk.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'werbenetzwerk')]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Werbenetzwerk
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: 'string', length: 5)]
|
||||
private string $werbenetzwerk;
|
||||
|
||||
#[ORM\Column(type: 'text')]
|
||||
private string $name;
|
||||
|
||||
#[ORM\Column(type: 'float')]
|
||||
private float $umrechnungskurs;
|
||||
|
||||
#[ORM\Column(type: 'smallint', options: ['unsigned' => true])]
|
||||
private int $eigenanteil_prozent;
|
||||
|
||||
#[ORM\Column(type: 'datetime', nullable: true)]
|
||||
private ?\DateTimeInterface $date_updated = null;
|
||||
|
||||
#[ORM\PrePersist]
|
||||
#[ORM\PreUpdate]
|
||||
public function setDateUpdatedValue(): void
|
||||
{
|
||||
$this->date_updated = new \DateTime();
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public function getWerbenetzwerk(): string
|
||||
{
|
||||
return $this->werbenetzwerk;
|
||||
}
|
||||
|
||||
public function setWerbenetzwerk(string $werbenetzwerk): self
|
||||
{
|
||||
$this->werbenetzwerk = $werbenetzwerk;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUmrechnungskurs(): float
|
||||
{
|
||||
return $this->umrechnungskurs;
|
||||
}
|
||||
|
||||
public function setUmrechnungskurs(float $umrechnungskurs): self
|
||||
{
|
||||
$this->umrechnungskurs = $umrechnungskurs;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEigenanteilProzent(): int
|
||||
{
|
||||
return $this->eigenanteil_prozent;
|
||||
}
|
||||
|
||||
public function setEigenanteilProzent(int $eigenanteil_prozent): self
|
||||
{
|
||||
$this->eigenanteil_prozent = $eigenanteil_prozent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateUpdated(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date_updated;
|
||||
}
|
||||
}
|
||||
112
src/Repository/UserRepository.php
Normal file
112
src/Repository/UserRepository.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Entity\User;
|
||||
|
||||
class UserRepository extends EntityRepository
|
||||
{
|
||||
/**
|
||||
* Findet einen User anhand der ID
|
||||
*/
|
||||
public function findById(int $id): ?User
|
||||
{
|
||||
return $this->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet einen User anhand des Usernames
|
||||
*/
|
||||
public function findByUsername(string $username): ?User
|
||||
{
|
||||
return $this->findOneBy(['username' => $username]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet einen User anhand der Email
|
||||
*/
|
||||
public function findByEmail(string $email): ?User
|
||||
{
|
||||
return $this->findOneBy(['email' => $email]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet alle User
|
||||
*/
|
||||
public function findAllUsers(): array
|
||||
{
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob ein Username bereits existiert
|
||||
*/
|
||||
public function usernameExists(string $username): bool
|
||||
{
|
||||
return $this->findByUsername($username) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft, ob eine Email bereits existiert
|
||||
*/
|
||||
public function emailExists(string $email): bool
|
||||
{
|
||||
return $this->findByEmail($email) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Findet User, die nach einem bestimmten Datum erstellt wurden
|
||||
*/
|
||||
public function findByCreatedAfter(\DateTime $date): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->where('u.createdAt > :date')
|
||||
->setParameter('date', $date)
|
||||
->orderBy('u.createdAt', 'DESC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht User nach Username (mit LIKE)
|
||||
*/
|
||||
public function searchByUsername(string $search): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->where('u.username LIKE :search')
|
||||
->setParameter('search', '%' . $search . '%')
|
||||
->orderBy('u.username', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zählt alle User
|
||||
*/
|
||||
public function countUsers(): int
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->select('COUNT(u.id)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert einen User
|
||||
*/
|
||||
public function save(User $user): void
|
||||
{
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht einen User
|
||||
*/
|
||||
public function delete(User $user): void
|
||||
{
|
||||
$this->getEntityManager()->remove($user);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user