Skip to content

Commit

Permalink
Merge pull request #49 from wanderlust-group-project-1/sandali
Browse files Browse the repository at this point in the history
GuideUpdate
  • Loading branch information
Sandali-Upekha authored Oct 31, 2023
2 parents 4439356 + c88a6ea commit 22dbb07
Show file tree
Hide file tree
Showing 5 changed files with 423 additions and 302 deletions.
2 changes: 0 additions & 2 deletions app/controllers/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public function update(string $a = '', string $b = '', string $c = ''):void {
$customer = new CustomerModel();
$customer->updateCustomer($_POST);



redirect('profile');
// $this->view('customer/profile');
}
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/Guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ public function find(string $a = '', string $b = '', string $c = ''):void {
$this->view('guide/find');
}

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

$guide = new guideModel();
$guide->updateGuide($_POST);

redirect('dashboard');
// $this->view('customer/profile');
}

}
24 changes: 21 additions & 3 deletions app/models/Guide.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

class GuideModel {
class GuideModel
{
use Model;

protected string $table = 'guides';
Expand All @@ -13,7 +14,8 @@ class GuideModel {
'user_id',
];

public function registerGuide(array $data) {
public function registerGuide(array $data)
{
if ($this->validateGuideSignup($data)) {
$user = new UserModel;

Expand All @@ -35,7 +37,8 @@ public function registerGuide(array $data) {
return false;
}

public function validateGuideSignup(array $data) {
public function validateGuideSignup(array $data)
{
$this->errors = [];

if (empty($data['name'])) {
Expand Down Expand Up @@ -72,4 +75,19 @@ public function validateGuideSignup(array $data) {

return empty($this->errors);
}

public function updateGuide(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');
}
}
Loading

0 comments on commit 22dbb07

Please sign in to comment.