Changed model structure

This commit is contained in:
2017-09-08 16:25:24 +07:00
parent 882e635081
commit 210c96e150
3 changed files with 39 additions and 51 deletions

View File

@@ -10,12 +10,12 @@ use Core\Hash;
class Home
{
public $access,
public $model,
$table;
public function __construct()
{
$this->access = new Access();
$this->model = new Access();
$this->table = 'user';
}
@@ -89,7 +89,7 @@ class Home
$args['full_name'] = htmlspecialchars($args['full_name']);
$args['username'] = htmlspecialchars($args['username']);
$data = $this->access->showAll($table);
$data = $this->model->showAll($table);
foreach ($data as $users) {
if ($args['username'] == $users['username']) {
Session::flash('info', 'Username telah digunakan. Silahkan gunakan username lain.');
@@ -98,7 +98,7 @@ class Home
}
}
$this->access->entry($table, $args);
$this->model->entry($table, $args);
Redirect::to('/');
}
@@ -109,7 +109,7 @@ class Home
$username = $args['username'];
$password = $args['password'];
$user = $this->access->showAll($table, [
$user = $this->model->showAll($table, [
['username', '=', $username]
]);
if ($user == false) {
@@ -121,11 +121,11 @@ class Home
if ($user['max_user'] <= 0) {
$info = "Telah mencapai maksimal user yang diizinkan. Silahkan logout pada perangkat lain terlebih dahulu.";
} else {
if ($this->access->update($table, ['status' => 1], $user['id']) != true) {
if ($this->model->update($table, ['status' => 1], $user['id']) != true) {
$info = "Terjadi kesalahan. Silahkan coba lagi dalam beberapa saat.";
} else {
$max_user = $user['max_user'] - 1;
if ($this->access->update($table, ['max_user' => $max_user], $user['id']) == true) {
if ($this->model->update($table, ['max_user' => $max_user], $user['id']) == true) {
Session::put('userid', $user['id']);
Session::put('username', $user['username']);
Session::put('full_name', $user['full_name']);
@@ -146,12 +146,12 @@ class Home
$table = 'user';
$userid = Session::get('userid');
$user = $this->access->showAll($table, [
$user = $this->model->showAll($table, [
['id', '=', $userid]
]);
$max_user = $user['max_user'] + 1;
if ($this->access->update(
if ($this->model->update(
$table,
[
'status' => 0,