Skip to content

Commit

Permalink
feat: user profile update
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavinda committed Oct 30, 2023
1 parent c40a79e commit ece0259
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 329 deletions.
2 changes: 2 additions & 0 deletions app/controllers/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Customer {

public function update(string $a = '', string $b = '', string $c = ''):void {

$customer = new CustomerModel();
$customer->updateCustomer($_POST);



Expand Down
45 changes: 45 additions & 0 deletions app/models/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,49 @@ public function validateCustomerSignup(array $data){

return empty($this->errors);
}

public function updateCustomer(array $data){

// $user = new UserModel;

$data['id'] = $_SESSION['USER']->id;

// alowed column
$data = array_filter($data, function ($key) {
return in_array($key, $this->allowedColumns);
}, ARRAY_FILTER_USE_KEY);

return $this->update($_SESSION['USER']->id,$data,'id');







}

// public function validateCustomerUpdate($data){
// $this->errors = [];

// if(empty($data['name'])){
// $this->errors['name'] = "Name is required";
// }

// if(empty($data['address'])){
// $this->errors['address'] = "Address is required";
// }

// if(empty($data['number'])){
// $this->errors['number'] = "Number is required";
// }

// if(empty($data['nic'])){
// $this->errors['nic'] = "NIC Number is required";
// }

// return empty($this->errors);
// }


}
329 changes: 0 additions & 329 deletions app/views/profile.view.php

This file was deleted.

0 comments on commit ece0259

Please sign in to comment.