Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
Fix increment id issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferry Ariawan committed Mar 25, 2021
1 parent 3f16ce6 commit ddc4415
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/controllers/ModulsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ public function postStep2()
}

$created_at = now();
$id = DB::table($this->table)->max('id') + 1;

$controller = CRUDBooster::generateController($table_name, $path);
DB::table($this->table)->insert(compact("controller", "name", "table_name", "icon", "path", "created_at", "id"));
Expand All @@ -347,7 +346,6 @@ public function postStep2()

$user_id_privileges = CRUDBooster::myPrivilegeId();
DB::table('cms_privileges_roles')->insert([
'id' => DB::table('cms_privileges_roles')->max('id') + 1,
'id_cms_moduls' => $id,
'id_cms_privileges' => $user_id_privileges,
'is_visible' => 1,
Expand Down Expand Up @@ -677,15 +675,13 @@ public function postAddSave()
}

$this->arr['created_at'] = date('Y-m-d H:i:s');
$this->arr['id'] = DB::table($this->table)->max('id') + 1;
DB::table($this->table)->insert($this->arr);

//Insert Menu
if ($this->arr['controller']) {
$parent_menu_sort = DB::table('cms_menus')->where('parent_id', 0)->max('sorting') + 1;
$parent_menu_id = DB::table('cms_menus')->max('id') + 1;
DB::table('cms_menus')->insert([
'id' => $parent_menu_id,
// $parent_menu_id = DB::table('cms_menus')->max('id') + 1;
$parent_menu_id = DB::table('cms_menus')->insertGetId([
'created_at' => date('Y-m-d H:i:s'),
'name' => $this->arr['name'],
'icon' => $this->arr['icon'],
Expand All @@ -697,7 +693,6 @@ public function postAddSave()
'parent_id' => 0,
]);
DB::table('cms_menus')->insert([
'id' => DB::table('cms_menus')->max('id') + 1,
'created_at' => date('Y-m-d H:i:s'),
'name' => cbLang("text_default_add_new_module", ['module' => $this->arr['name']]),
'icon' => 'fa fa-plus',
Expand All @@ -709,7 +704,6 @@ public function postAddSave()
'parent_id' => $parent_menu_id,
]);
DB::table('cms_menus')->insert([
'id' => DB::table('cms_menus')->max('id') + 1,
'created_at' => date('Y-m-d H:i:s'),
'name' => cbLang("text_default_list_module", ['module' => $this->arr['name']]),
'icon' => 'fa fa-bars',
Expand All @@ -726,7 +720,6 @@ public function postAddSave()

$user_id_privileges = CRUDBooster::myPrivilegeId();
DB::table('cms_privileges_roles')->insert([
'id' => DB::table('cms_privileges_roles')->max('id') + 1,
'id_cms_moduls' => $id_modul,
'id_cms_privileges' => $user_id_privileges,
'is_visible' => 1,
Expand Down
1 change: 0 additions & 1 deletion src/controllers/PrivilegesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public function postEditSave($id)
DB::table('cms_privileges_roles')->where('id', $currentPermission->id)->update($arrs);
} else {
$arrs = [];
$arrs['id'] = DB::table('cms_privileges_roles')->max('id') + 1;
$arrs['is_visible'] = @$data['is_visible'] ?: 0;
$arrs['is_create'] = @$data['is_create'] ?: 0;
$arrs['is_read'] = @$data['is_read'] ?: 0;
Expand Down
1 change: 0 additions & 1 deletion src/helpers/CRUDBooster.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public static function getSetting($name)

public static function insert($table, $data = [])
{
$data['id'] = DB::table($table)->max('id') + 1;
if (! $data['created_at']) {
if (Schema::hasColumn($table, 'created_at')) {
$data['created_at'] = date('Y-m-d H:i:s');
Expand Down

0 comments on commit ddc4415

Please sign in to comment.