1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Display name instead of id

Discussion in 'PHP' started by neilfurry, Aug 30, 2022.

  1. #1
    Hi,

    Im working with symfony framework and need help.

    I have two entities: Members and Loans.

    So basically Each Member will have many loans. These are the entities i created:
    
    namespace App\Entity;
    
    use App\Repository\LoansRepository;
    use Doctrine\ORM\Mapping as ORM;
    
    /**
    * @ORM\Entity(repositoryClass=LoansRepository::class)
    */
    class Loans
    {
        /**
         * @ORM\Id
         * @ORM\GeneratedValue
         * @ORM\Column(type="integer")
         */
        private $id;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $LoanApplicationNumber;
    
        /**
         * @ORM\Column(type="string", length=255)
         * @ORM\OneToMany(targetEntity="Members", mappedBy="id")
         */
        private $Loanee;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $LoanAmount;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $MonthsToPay;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $LoanPurpose;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $ModeOfPayment;
    
        /**
         * @ORM\Column(type="date")
         */
        private $DateApplied;
    
        /**
         * @ORM\Column(type="datetime")
         */
        private $DateEncoded;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $ChairApproved;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $GenApproved;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $TeasApproved;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $LoanType;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $Principal;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $MonthlyInstallment;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=3)
         */
        private $ContractRate;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $OtherCharges;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $NoOfInstallment;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=2)
         */
        private $InterestRate;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $MonthlyRate;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $PMR;
    
        /**
         * @ORM\Column(type="integer")
         */
        private $BaseInterestRate;
    
        /**
         * @ORM\Column(type="date")
         */
        private $DeductionStart;
    
        /**
         * @ORM\Column(type="date")
         */
        private $DeductionEnd;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=2)
         */
        private $ProcessingFee;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=2)
         */
        private $ComputerFee;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=2)
         */
        private $Capital;
    
        /**
         * @ORM\Column(type="decimal", precision=10, scale=2)
         */
        private $NetLoan;
    
        public function getId(): ?int
        {
            return $this->id;
        }
    
        public function getLoanApplicationNumber(): ?string
        {
            return $this->LoanApplicationNumber;
        }
    
        public function setLoanApplicationNumber(string $LoanApplicationNumber): self
        {
            $this->LoanApplicationNumber = $LoanApplicationNumber;
    
            return $this;
        }
    
        public function getLoanee(): ?string
        {
            return $this->Loanee;
        }
    
        public function setLoanee(string $Loanee): self
        {
            $this->Loanee = $Loanee;
    
            return $this;
        }
    
        public function getLoanAmount(): ?string
        {
            return $this->LoanAmount;
        }
    
        public function setLoanAmount(string $LoanAmount): self
        {
            $this->LoanAmount = $LoanAmount;
    
            return $this;
        }
    
        public function getMonthsToPay(): ?string
        {
            return $this->MonthsToPay;
        }
    
        public function setMonthsToPay(string $MonthsToPay): self
        {
            $this->MonthsToPay = $MonthsToPay;
    
            return $this;
        }
    
        public function getLoanPurpose(): ?string
        {
            return $this->LoanPurpose;
        }
    
        public function setLoanPurpose(string $LoanPurpose): self
        {
            $this->LoanPurpose = $LoanPurpose;
    
            return $this;
        }
    
        public function getModeOfPayment(): ?string
        {
            return $this->ModeOfPayment;
        }
    
        public function setModeOfPayment(string $ModeOfPayment): self
        {
            $this->ModeOfPayment = $ModeOfPayment;
    
            return $this;
        }
    
        public function getDateApplied(): ?\DateTimeInterface
        {
            return $this->DateApplied;
        }
    
        public function setDateApplied(\DateTimeInterface $DateApplied): self
        {
            $this->DateApplied = $DateApplied;
    
            return $this;
        }
    
        public function getDateEncoded(): ?\DateTimeInterface
        {
            return $this->DateEncoded;
        }
    
        public function setDateEncoded(\DateTimeInterface $DateEncoded): self
        {
            $this->DateEncoded = $DateEncoded;
    
            return $this;
        }
    
        public function getChairApproved(): ?string
        {
            return $this->ChairApproved;
        }
    
        public function setChairApproved(string $ChairApproved): self
        {
            $this->ChairApproved = $ChairApproved;
    
            return $this;
        }
    
        public function getGenApproved(): ?string
        {
            return $this->GenApproved;
        }
    
        public function setGenApproved(string $GenApproved): self
        {
            $this->GenApproved = $GenApproved;
    
            return $this;
        }
    
        public function getTeasApproved(): ?string
        {
            return $this->TeasApproved;
        }
    
        public function setTeasApproved(string $TeasApproved): self
        {
            $this->TeasApproved = $TeasApproved;
    
            return $this;
        }
    
        public function getLoanType(): ?string
        {
            return $this->LoanType;
        }
    
        public function setLoanType(string $LoanType): self
        {
            $this->LoanType = $LoanType;
    
            return $this;
        }
    
        public function getPrincipal(): ?int
        {
            return $this->Principal;
        }
    
        public function setPrincipal(int $Principal): self
        {
            $this->Principal = $Principal;
    
            return $this;
        }
    
        public function getMonthlyInstallment(): ?int
        {
            return $this->MonthlyInstallment;
        }
    
        public function setMonthlyInstallment(int $MonthlyInstallment): self
        {
            $this->MonthlyInstallment = $MonthlyInstallment;
    
            return $this;
        }
    
        public function getContractRate(): ?string
        {
            return $this->ContractRate;
        }
    
        public function setContractRate(string $ContractRate): self
        {
            $this->ContractRate = $ContractRate;
    
            return $this;
        }
    
        public function getOtherCharges(): ?int
        {
            return $this->OtherCharges;
        }
    
        public function setOtherCharges(int $OtherCharges): self
        {
            $this->OtherCharges = $OtherCharges;
    
            return $this;
        }
    
        public function getNoOfInstallment(): ?int
        {
            return $this->NoOfInstallment;
        }
    
        public function setNoOfInstallment(int $NoOfInstallment): self
        {
            $this->NoOfInstallment = $NoOfInstallment;
    
            return $this;
        }
    
        public function getInterestRate(): ?string
        {
            return $this->InterestRate;
        }
    
        public function setInterestRate(string $InterestRate): self
        {
            $this->InterestRate = $InterestRate;
    
            return $this;
        }
    
        public function getMonthlyRate(): ?int
        {
            return $this->MonthlyRate;
        }
    
        public function setMonthlyRate(int $MonthlyRate): self
        {
            $this->MonthlyRate = $MonthlyRate;
    
            return $this;
        }
    
        public function getPMR(): ?int
        {
            return $this->PMR;
        }
    
        public function setPMR(int $PMR): self
        {
            $this->PMR = $PMR;
    
            return $this;
        }
    
        public function getBaseInterestRate(): ?string
        {
            return $this->BaseInterestRate;
        }
    
        public function setBaseInterestRate(string $BaseInterestRate): self
        {
            $this->BaseInterestRate = $BaseInterestRate;
    
            return $this;
        }
    
        public function getDeductionStart(): ?\DateTimeInterface
        {
            return $this->DeductionStart;
        }
    
        public function setDeductionStart(\DateTimeInterface $DeductionStart): self
        {
            $this->DeductionStart = $DeductionStart;
    
            return $this;
        }
    
        public function getDeductionEnd(): ?\DateTimeInterface
        {
            return $this->DeductionEnd;
        }
    
        public function setDeductionEnd(\DateTimeInterface $DeductionEnd): self
        {
            $this->DeductionEnd = $DeductionEnd;
    
            return $this;
        }
    
        public function getProcessingFee(): ?string
        {
            return $this->ProcessingFee;
        }
    
        public function setProcessingFee(string $ProcessingFee): self
        {
            $this->ProcessingFee = $ProcessingFee;
    
            return $this;
        }
    
        public function getComputerFee(): ?string
        {
            return $this->ComputerFee;
        }
    
        public function setComputerFee(string $ComputerFee): self
        {
            $this->ComputerFee = $ComputerFee;
    
            return $this;
        }
    
        public function getCapital(): ?string
        {
            return $this->Capital;
        }
    
        public function setCapital(string $Capital): self
        {
            $this->Capital = $Capital;
    
            return $this;
        }
    
        public function getNetLoan(): ?string
        {
            return $this->NetLoan;
        }
    
        public function setNetLoan(string $NetLoan): self
        {
            $this->NetLoan = $NetLoan;
    
            return $this;
        }
    
       
        
    
        
    }
    
    PHP:
    This is the Members entity:

    amespace App\Entity;
    
    use App\Repository\MembersRepository;
    use Doctrine\ORM\Mapping as ORM;
    
    /**
    * @ORM\Entity(repositoryClass=MembersRepository::class)
    */
    class Members
    {
        /**
         * @ORM\Id
         * @ORM\GeneratedValue
         * @ORM\Column(type="integer")
         * @ORM\ManyToOne(targetEntity="Loans", inversedBy="Loanee")
         */
        private $id;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $LastName;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $FirstName;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $MiddleName;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $ResidencePhone;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $Address;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $Barangay;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $Email;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $MobileNumber;
    
        /**
         * @ORM\Column(type="date")
         */
        private $Birthday;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $BirthPlace;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $CivilStatus;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $Sex;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $Citizenship;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $EmployeeNumber;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $TIN;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $GSIS;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $Agency;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $Designation;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $OfficePhone;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $EmployeeStatus;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $SourceOfIncome;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $MonthlyIncome;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $EducationalAttainment;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $Spouse;
    
        /**
         * @ORM\Column(type="string", length=255, nullable=true)
         */
        private $Dependents;
    
        /**
         * @ORM\Column(type="datetime")
         */
        private $DateRegistered;
    
        /**
         * @ORM\Column(type="datetime")
         */
        private $DateLastUpdated;
    
        /**
         * @ORM\Column(type="string", length=255)
         */
        private $BoardAction;
    
        public function getId(): ?int
        {
            return $this->id;
        }
    
        public function getLastName(): ?string
        {
            return $this->LastName;
        }
    
        public function setLastName(string $LastName): self
        {
            $this->LastName = $LastName;
    
            return $this;
        }
    
        public function getFirstName(): ?string
        {
            return $this->FirstName;
        }
    
        public function setFirstName(string $FirstName): self
        {
            $this->FirstName = $FirstName;
    
            return $this;
        }
    
        public function getMiddleName(): ?string
        {
            return $this->MiddleName;
        }
    
        public function setMiddleName(?string $MiddleName): self
        {
            $this->MiddleName = $MiddleName;
    
            return $this;
        }
    
        public function getResidencePhone(): ?string
        {
            return $this->ResidencePhone;
        }
    
        public function setResidencePhone(?string $ResidencePhone): self
        {
            $this->ResidencePhone = $ResidencePhone;
    
            return $this;
        }
    
        public function getAddress(): ?string
        {
            return $this->Address;
        }
    
        public function setAddress(string $Address): self
        {
            $this->Address = $Address;
    
            return $this;
        }
    
        public function getBarangay(): ?string
        {
            return $this->Barangay;
        }
    
        public function setBarangay(string $Barangay): self
        {
            $this->Barangay = $Barangay;
    
            return $this;
        }
    
        public function getEmail(): ?string
        {
            return $this->Email;
        }
    
        public function setEmail(?string $Email): self
        {
            $this->Email = $Email;
    
            return $this;
        }
    
        public function getMobileNumber(): ?string
        {
            return $this->MobileNumber;
        }
    
        public function setMobileNumber(string $MobileNumber): self
        {
            $this->MobileNumber = $MobileNumber;
    
            return $this;
        }
    
        public function getBirthday(): ?\DateTimeInterface
        {
            return $this->Birthday;
        }
    
        public function setBirthday(\DateTimeInterface $Birthday): self
        {
            $this->Birthday = $Birthday;
    
            return $this;
        }
    
        public function getBirthPlace(): ?string
        {
            return $this->BirthPlace;
        }
    
        public function setBirthPlace(string $BirthPlace): self
        {
            $this->BirthPlace = $BirthPlace;
    
            return $this;
        }
    
        public function getCivilStatus(): ?string
        {
            return $this->CivilStatus;
        }
    
        public function setCivilStatus(string $CivilStatus): self
        {
            $this->CivilStatus = $CivilStatus;
    
            return $this;
        }
    
        public function getSex(): ?string
        {
            return $this->Sex;
        }
    
        public function setSex(string $Sex): self
        {
            $this->Sex = $Sex;
    
            return $this;
        }
    
        public function getCitizenship(): ?string
        {
            return $this->Citizenship;
        }
    
        public function setCitizenship(?string $Citizenship): self
        {
            $this->Citizenship = $Citizenship;
    
            return $this;
        }
    
        public function getEmployeeNumber(): ?string
        {
            return $this->EmployeeNumber;
        }
    
        public function setEmployeeNumber(string $EmployeeNumber): self
        {
            $this->EmployeeNumber = $EmployeeNumber;
    
            return $this;
        }
    
        public function getTIN(): ?string
        {
            return $this->TIN;
        }
    
        public function setTIN(?string $TIN): self
        {
            $this->TIN = $TIN;
    
            return $this;
        }
    
        public function getGSIS(): ?string
        {
            return $this->GSIS;
        }
    
        public function setGSIS(?string $GSIS): self
        {
            $this->GSIS = $GSIS;
    
            return $this;
        }
    
        public function getAgency(): ?string
        {
            return $this->Agency;
        }
    
        public function setAgency(string $Agency): self
        {
            $this->Agency = $Agency;
    
            return $this;
        }
    
        public function getDesignation(): ?string
        {
            return $this->Designation;
        }
    
        public function setDesignation(string $Designation): self
        {
            $this->Designation = $Designation;
    
            return $this;
        }
    
        public function getOfficePhone(): ?string
        {
            return $this->OfficePhone;
        }
    
        public function setOfficePhone(?string $OfficePhone): self
        {
            $this->OfficePhone = $OfficePhone;
    
            return $this;
        }
    
        public function getEmployeeStatus(): ?string
        {
            return $this->EmployeeStatus;
        }
    
        public function setEmployeeStatus(string $EmployeeStatus): self
        {
            $this->EmployeeStatus = $EmployeeStatus;
    
            return $this;
        }
    
        public function getSourceOfIncome(): ?string
        {
            return $this->SourceOfIncome;
        }
    
        public function setSourceOfIncome(string $SourceOfIncome): self
        {
            $this->SourceOfIncome = $SourceOfIncome;
    
            return $this;
        }
    
        public function getMonthlyIncome(): ?string
        {
            return $this->MonthlyIncome;
        }
    
        public function setMonthlyIncome(string $MonthlyIncome): self
        {
            $this->MonthlyIncome = $MonthlyIncome;
    
            return $this;
        }
    
        public function getEducationalAttainment(): ?string
        {
            return $this->EducationalAttainment;
        }
    
        public function setEducationalAttainment(?string $EducationalAttainment): self
        {
            $this->EducationalAttainment = $EducationalAttainment;
    
            return $this;
        }
    
        public function getSpouse(): ?string
        {
            return $this->Spouse;
        }
    
        public function setSpouse(?string $Spouse): self
        {
            $this->Spouse = $Spouse;
    
            return $this;
        }
    
        public function getDependents(): ?string
        {
            return $this->Dependents;
        }
    
        public function setDependents(?string $Dependents): self
        {
            $this->Dependents = $Dependents;
    
            return $this;
        }
    
        public function getDateRegistered(): ?\DateTimeInterface
        {
            return $this->DateRegistered;
        }
    
        public function setDateRegistered(\DateTimeInterface $DateRegistered): self
        {
            $this->DateRegistered = $DateRegistered;
    
            return $this;
        }
    
        public function getDateLastUpdated(): ?\DateTimeInterface
        {
            return $this->DateLastUpdated;
        }
    
        public function setDateLastUpdated(\DateTimeInterface $DateLastUpdated): self
        {
            $this->DateLastUpdated = $DateLastUpdated;
    
            return $this;
        }
    
        public function getBoardAction(): ?string
        {
            return $this->BoardAction;
        }
    
        public function setBoardAction(string $BoardAction): self
        {
            $this->BoardAction = $BoardAction;
    
            return $this;
        }
    }
    
    PHP:
    I need to display on the table the name of the Member, instead of its id

    as shown on this image:

    upload_2022-8-31_11-3-25.png

    Thank you very much!
     
    neilfurry, Aug 30, 2022 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I don't know symfony, nor how this table is constructed. Lets assume it's standard PHP and HTML (no javascript, no json)

    When the code loops through the data to output the table you'll be able to see what data is held in the results. If you're lucky the name will be in there. If not, you need to find where the query is run and add those columns to the query, then output them in the loop.
     
    sarahk, Aug 30, 2022 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    I'm genuinely not sure what the devil the "endless pointless getter/setter for nothing" has to do with your output. None of the code you presented would/should even be related to what you're trying to do.

    It is however an excellent example of why I consider frameworks to be incompetent code-bloat trash that does nobody any favors. What I'd suggest is pitching the framework crap in the garbage and starting over clean.
     
    deathshadow, Aug 31, 2022 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #4
    I'm guessing that if the OP can't work out how to add info to a table they're probably going to have a massive learning curve to "start over clean" that they may not have the time or motivation to commit to.
     
    sarahk, Aug 31, 2022 IP