I am trying to create a little rental project where I basically currently have a table which shows 5 types of values which are taken from a database (mySQL) and are shown with the help of twig.
A MVC structure is applied.
Visual representation:

Sorry, I blocked the information out because the addresses and whatnot are actually real.
And now to the issue: I'd like to be able to add a customer (and later on edit and remove as well, but first things first.)
I put this in my CustomerModel.php file:
class CustomerModel extends AbstractModel {
public function addCustomer($customerNumber, $customerName, $customerAddress, $postalAddress, $phoneNumber) {
$customersQuery = "INSERT INTO Customers(customerNumber, customerName, customerAddress, postalAddress, phoneNumber) " .
"VALUES(:customerNumber, :customerName, :customerAddress, :postalAddress, :phoneNumber)";
$customersStatement = $this->db->prepare($customersQuery);
$customersStatement->execute(["customerNumber" => $customerNumber,
"customerName" => $customerName,
"customerAddress" => $customerAddress,
"postalAddress" => $postalAddress,
"phoneNumber" => $phoneNumber]);
if (!$customersStatement) die("Fatal error.");
$customerNumber = $this->db->lastInsertId();
return $customerNumber;
}
and this in CustomerController.php
class CustomerController extends AbstractController {
public function addCustomer() {
return $this->render("AddCustomer.twig", []);
}
public function customerAdded() {
$form = $this->request->getForm();
$customerName = $form["customerName"];
$customerModel = new CustomerModel($this->db);
// $customerNumber = $customerModel->addCustomer($customerNumber, $customerName, $customerAddress, $postalAddress, $phoneNumber);
$customerNumber = $customerModel->addCustomer($customerName);
$customerAddress = $customerModel->addCustomer($customerName);
$postalAddress = $customerModel->addCustomer($customerName);
$phoneNumber = $customerModel->addCustomer($customerName);
$properties = ["customerNumber" => $customerNumber,
"customerName" => $customerName,
"customerAddress" => $customerAddress,
"postalAddress" => $postalAddress,
"phoneNumber" => $phoneNumber];
return $this->render("CustomerAdded.twig", $properties);
}
}
and now when I try to enter the information in my form, I get the errors:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Carrental\Models\CustomerModel::addCustomer(), 1 passed in /home/vagrant/code/assignments/XXXX/src/Controllers/CustomerController.php on line 18 and exactly 5 expected in /home/vagrant/code/assignments/XXXX/src/Models/CustomerModel.php on line 11
( ! ) ArgumentCountError: Too few arguments to function Carrental\Models\CustomerModel::addCustomer(), 1 passed in /home/vagrant/code/assignments/XXXX/src/Controllers/CustomerController.php on line 18 and exactly 5 expected in /home/vagrant/code/assignments/XXXX/src/Models/CustomerModel.php on line 11
Clearly, there is something I definitely don't understand with what I have done..
Many thanks in advance.