add phone number, notes, and contact person to carrier

This commit is contained in:
Yisroel Baum 2025-11-10 11:14:32 +02:00
parent f37868f0d0
commit a739479e22
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
9 changed files with 88 additions and 6 deletions

View file

@ -8,6 +8,9 @@ class Carrier
private ?int $id,
private string $email,
private string $companyName,
private string $contactPerson,
private string $phoneNumber,
private string $notes,
) {}
public function getId(): ?int
@ -29,4 +32,19 @@ class Carrier
{
return $this->companyName;
}
public function getContactPerson(): string
{
return $this->contactPerson;
}
public function getPhoneNumber(): string
{
return $this->phoneNumber;
}
public function getNotes(): string
{
return $this->notes;
}
}

View file

@ -32,7 +32,10 @@ class CarrierController
$body = $request->getParsedBody();
$dto = new CreateCarrierRequest(
$body['email'],
$body['companyName'],
$body['company_name'],
$body['contact_person'],
$body['phone_number'],
$body['notes'],
);
$useCase = new CreateCarrier($dto, $this->carrierRepo);
$useCase->execute();

View file

@ -31,6 +31,9 @@ class FlatFileCarrierRepository implements CarrierRepository
$jsonCarrier['id'],
$jsonCarrier['email'],
$jsonCarrier['companyName'],
$jsonCarrier['contactPerson'],
$jsonCarrier['phoneNumber'],
$jsonCarrier['notes'],
);
}
}
@ -38,6 +41,9 @@ class FlatFileCarrierRepository implements CarrierRepository
'id' => $this->autoIncrementId($data),
'email' => $carrier->getEmail(),
'companyName' => $carrier->getCompanyName(),
'contactPerson' => $carrier->getContactPerson(),
'phoneNumber' => $carrier->getPhoneNumber(),
'notes' => $carrier->getNotes(),
];
$data[] = $newCarrier;
file_put_contents(
@ -48,6 +54,9 @@ class FlatFileCarrierRepository implements CarrierRepository
$newCarrier['id'],
$newCarrier['email'],
$newCarrier['companyName'],
$newCarrier['contactPerson'],
$newCarrier['phoneNumber'],
$newCarrier['notes'],
);
}
@ -60,7 +69,10 @@ class FlatFileCarrierRepository implements CarrierRepository
return new Carrier(
$carrier['id'],
$carrier['email'],
$carrier['companyName']
$carrier['companyName'],
$carrier['contactPerson'],
$carrier['phoneNumber'],
$carrier['notes'],
);
}, $this->getCarrierData());
}

View file

@ -17,7 +17,10 @@ class CreateCarrier
$carrier = new Carrier(
null,
$this->dto->email,
$this->dto->companyName
$this->dto->companyName,
$this->dto->contactPerson,
$this->dto->phoneNumber,
$this->dto->notes,
);
return $this->carrierRepo->save($carrier);

View file

@ -7,5 +7,8 @@ class CreateCarrierRequest
public function __construct(
public string $email,
public string $companyName,
public string $contactPerson,
public string $phoneNumber,
public string $notes,
) {}
}