From c0ed31177437caf4b78615e1f94a572340aa04a2 Mon Sep 17 00:00:00 2001 From: Agung Sugiarto Date: Sat, 22 Aug 2020 11:58:43 +0700 Subject: [PATCH] update result menu with getRow --- src/Models/MenuModel.php | 4 ++-- src/Views/Menu/index.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Models/MenuModel.php b/src/Models/MenuModel.php index 89baf08..eed5ea8 100644 --- a/src/Models/MenuModel.php +++ b/src/Models/MenuModel.php @@ -96,7 +96,7 @@ private function getMenuDriverMySQLi($id) ->join('auth_groups', 'groups_menu.group_id = auth_groups.id', 'left') ->where('menu.id', $id) ->get() - ->getResultArray(); + ->getRow(); } /** @@ -115,7 +115,7 @@ private function getMenuDRiverPostgre($id) ->where('menu.id', $id) ->groupBy(['menu.id', 'groups_menu.menu_id']) ->get() - ->getResultArray(); + ->getRow(); } /** diff --git a/src/Views/Menu/index.php b/src/Views/Menu/index.php index 9cdab7f..56d3213 100644 --- a/src/Views/Menu/index.php +++ b/src/Views/Menu/index.php @@ -242,18 +242,18 @@ function menu() { }); var editForm = $('#form-edit'); - var group_id = response.data[0].group_id; + var group_id = response.data.group_id; var group = group_id.split('|'); - var parent_id = response.data[0].parent_id == 0 ? 0 : response.data[0].parent_id; + var parent_id = response.data.parent_id == 0 ? 0 : response.data.parent_id; - editForm.find('select[name="active"]').val(response.data[0].active).change(); + editForm.find('select[name="active"]').val(response.data.active).change(); editForm.find('select[name="parent_id"]').val(parent_id).change(); editForm.find('select[name="groups_menu[]"]').val(group).change(); - editForm.find('input[name="icon"]').val(response.data[0].icon); - editForm.find('input[name="icon"]').val(response.data[0].icon); - editForm.find('input[name="title"]').val(response.data[0].title); - editForm.find('input[name="route"]').val(response.data[0].route); - $("#menu_id").val(response.data[0].id); + editForm.find('input[name="icon"]').val(response.data.icon); + editForm.find('input[name="icon"]').val(response.data.icon); + editForm.find('input[name="title"]').val(response.data.title); + editForm.find('input[name="route"]').val(response.data.route); + $("#menu_id").val(response.data.id); $('#modal-update').modal('show'); }).fail((jqXHR, textStatus, errorThrown) => { @@ -324,7 +324,7 @@ function menu() { }) $('#modal-edit').on('hidden.bs.modal', function() { - $(this).find('#form-edit')[0].reset(); + $(this).find('#form-edit').reset(); $('.is-invalid').removeClass('is-invalid'); $('.invalid-feedback').removeClass('invalid-feedback'); });