Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

src/Agenda/Company/Domain/Model/Company.php

Open in GitHub
namespace Src\Agenda\Company\Domain\Model;
 
use Src\Agenda\Company\Domain\Model\Entities\Address;
use Src\Agenda\Company\Domain\Model\Entities\Contact;
use Src\Agenda\Company\Domain\Model\Entities\Department;
use Src\Agenda\Company\Domain\Model\ValueObjects\Addresses;
use Src\Agenda\Company\Domain\Model\ValueObjects\Contacts;
use Src\Agenda\Company\Domain\Model\ValueObjects\Departments;
use Src\Agenda\Company\Domain\Model\ValueObjects\FiscalName;
use Src\Agenda\Company\Domain\Model\ValueObjects\SocialName;
use Src\Agenda\Company\Domain\Model\ValueObjects\Vat;
use Src\Common\Domain\AggregateRoot;
 
class Company extends AggregateRoot
{
public function __construct(
public readonly ?int $id,
public readonly FiscalName $fiscal_name,
public readonly SocialName $social_name,
public readonly Vat $vat,
public readonly Addresses $addresses,
public readonly Departments $departments,
public readonly Contacts $contacts,
public readonly bool $is_active = true
) {}
 
public function addAddress(Address $address): void
{
$this->addresses->add($address);
}
 
public function updateAddress(Address $newAddress): void
{
$this->addresses->update($newAddress);
}
 
public function removeAddress(int $address_id): void
{
$this->addresses->remove($address_id);
}
 
public function toArray(): array
{
return [
'id' => $this->id,
'fiscal_name' => $this->fiscal_name,
'social_name' => $this->social_name,
'vat' => $this->vat,
'addresses' => $this->addresses,
'departments' => $this->departments,
'contacts' => $this->contacts,
'is_active' => $this->is_active,
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.