Melakukan Perubahan pada pengguna

This commit is contained in:
Vinsensiaaa
2024-03-04 16:01:10 +07:00
parent cceedcd9c0
commit e71c3eed38
4 changed files with 67 additions and 22 deletions
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Models\User;
use App\Models\Role;
use App\Models\Pengaturan;
use App\Models\Roless;
use App\Models\RoleUser;
use Illuminate\Http\Request;
@@ -25,7 +26,8 @@ class MstPenggunaController extends Controller
{
$data = null;
// $data = User::where('role_name', "<>", "superadmin")->latest()->paginate(10);
return view('admin.mst_pengguna.index',compact('data'))
$pengaturan = Pengaturan::where("id",1)->first();
return view('admin.mst_pengguna.index',compact('data', 'pengaturan'))
->with('i', (request()->input('page', 1) - 1) * 10);
}
@@ -171,7 +173,7 @@ class MstPenggunaController extends Controller
->with('success','Lock upload data sudah diubah!');
}
public function lockTambahData($userId="", $reset=0, Request $req)
public function lockTambahData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_tambah_data"=>$reset == 0 ? 1:0,
@@ -181,6 +183,15 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_tambah_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_tambah"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_tambah"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
@@ -191,7 +202,7 @@ class MstPenggunaController extends Controller
}
public function lockUbahData($userId="", $reset=0, Request $req)
public function lockUbahData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_ubah_data"=>$reset == 0 ? 1:0,
@@ -200,6 +211,14 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_ubah_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_ubah"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_ubah"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
@@ -210,7 +229,7 @@ class MstPenggunaController extends Controller
}
public function lockHapusData($userId="", $reset=0, Request $req)
public function lockHapusData($userId="", $reset=0, $check=0, Request $req)
{
$updateValue = [
"lock_hapus_data"=>$reset == 0 ? 1:0,
@@ -219,6 +238,14 @@ class MstPenggunaController extends Controller
if (empty($userId))
{
if ($check==2){
$updateValue = [
"lock_hapus_data"=>0,
];
Pengaturan::where("id",1)->update(["check_all_hapus"=>0]);
}else{
Pengaturan::where("id",1)->update(["check_all_hapus"=>1]);
}
User::query()->update($updateValue);
}else{
User::where(["id"=>$userId])->update($updateValue);
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Permission\Traits\HasPermissions;
class Pengaturan extends Model
{
use HasFactory, HasPermissions;
protected $table = 'pengaturan';
protected $fillable = [
'check_all_tambah',
'check_all_hapus',
'check_all_ubah'
];
}