1

Kindly can someone guide me on how to achieve this?

  • Create a class Company and define attributes Company Name, Company Address.
  • Create a class Employees and define attributes Employee Name, Phone Number, and Email.
  • Create a relationship between the above two classes where a Company can have multiple Employees in such a way as to retrieve company and its employee information through its Company object.
Muhammad Yasir
  • 406
  • 3
  • 15
  • 1
    Learn the basics. https://www.php.net/manual/en/language.oop5.php – Markus Zeller Aug 31 '22 at 17:01
  • 1
    Since it seems like you want to work with classes that store information, you might want to look at using Doctrine ORM. Using Doctrine to do this can help you guide yourself through this process. https://www.doctrine-project.org/projects/orm.html I also agree with Markus that reading about the basics would be great :) – thomasberends Aug 31 '22 at 18:24
  • If you feel that my reply is helpful, then you can upvote or mark my reply as an answer to simplify the future search of other users. [How does accepting an answer work?](https://meta.stackexchange.com/a/5235/309682) – StepUp Sep 03 '22 at 14:33

1 Answers1

1

You need to create Employee class:

class Employee 
{
    public $name
    public $phoneNumber
    public $mail
}

and Company class:

class Company 
{
    public $name;
    public $address;
    public $matchCount;
    public $employees = array();
}

You can use the following snippet:

$company = new Company();
$company->employees[0] = new Employee();
StepUp
  • 36,391
  • 15
  • 88
  • 148