Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add membershipStatus to member revision #157

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions migrations/Version20240224201202.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240224201202 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE admin_member_revision ADD current_membership_status_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE admin_member_revision ADD CONSTRAINT FK_A66E5AC1E1F48A9F FOREIGN KEY (current_membership_status_id) REFERENCES admin_membershipstatus (id)');
$this->addSql('CREATE INDEX IDX_A66E5AC1E1F48A9F ON admin_member_revision (current_membership_status_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE admin_member_revision DROP FOREIGN KEY FK_A66E5AC1E1F48A9F');
$this->addSql('DROP INDEX IDX_A66E5AC1E1F48A9F ON admin_member_revision');
$this->addSql('ALTER TABLE admin_member_revision DROP current_membership_status_id');
}
}
17 changes: 17 additions & 0 deletions src/Entity/MemberDetailsRevision.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Symfony\Component\Security\Core\User\UserInterface;
use App\Repository\MemberRepository;

use App\Entity\Membership\MembershipStatus;

/**
* @ORM\Entity
* @ORM\Table("admin_member_revision")
Expand Down Expand Up @@ -64,6 +66,11 @@ class MemberDetailsRevision {
/** @ORM\Column(type="date", nullable=true) */
private ?DateTime $dateOfBirth = null;

/**
* @ORM\ManyToOne(targetEntity="App\Entity\Membership\MembershipStatus")
*/
private ?MembershipStatus $currentMembershipStatus = null;

public function __construct(Member $member, bool $own) {
$this->member = $member;
$this->own = $own;
Expand All @@ -79,6 +86,7 @@ public function __construct(Member $member, bool $own) {
$this->postCode = $member->getPostCode();
$this->country = $member->getCountry();
$this->dateOfBirth = $member->getDateOfBirth();
$this->currentMembershipStatus = $member->getCurrentMembershipStatus();
}

public function hasChanged(Member $member) {
Gwildor marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -93,6 +101,7 @@ public function hasChanged(Member $member) {
|| $this->getEmail() !== $member->getEmail()
|| $this->getPostCode() !== $member->getPostCode()
|| $this->getCountry() !== $member->getCountry()
|| $this->getCurrentMembershipStatus() !== $member->getCurrentMembershipStatus()
|| $this->getDateOfBirth()->format('Ymd') !== $member->getDateOfBirth('Ymd');
}

Expand All @@ -111,4 +120,12 @@ public function getPostCode(): string { return $this->postCode; }
public function getCountry(): string { return $this->country; }
public function getDateOfBirth(): ?DateTime { return $this->dateOfBirth; }

public function getCurrentMembershipStatus(): ?MembershipStatus {
return $this->currentMembershipStatus;
}

public function setCurrentMembershipStatus(?MembershipStatus $membershipStatus): void {
$this->currentMembershipStatus = $membershipStatus;
}

}
Loading