add banned & status
pengurusan pengguna - admin
This commit is contained in:
@@ -138,26 +138,32 @@ class PembidaController extends Controller
|
||||
return view('pembida.kemaskini',compact('user','files'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $userid)
|
||||
public function update(Request $request)
|
||||
{
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
$user = User::where('id','=',$userid)->first();
|
||||
dd($user->status);
|
||||
if($request->status == true)
|
||||
{
|
||||
$status = 'active';
|
||||
}
|
||||
else if($request->statusban == true)
|
||||
{
|
||||
$status = 'banned';
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = 'inactive';
|
||||
}
|
||||
|
||||
$user = User::where('id','=',$request->userid)->first();
|
||||
// dd($user);
|
||||
$user->email = $request->email;
|
||||
$user->notelbimbit = $request->notelbimbit;
|
||||
$user->nokp = $request->nokp;
|
||||
$user->updated_at = $currentdate;
|
||||
|
||||
if($user->status == 'on')
|
||||
{
|
||||
$user->status = 'active';
|
||||
}
|
||||
else
|
||||
{
|
||||
$user->status == 'inactive';
|
||||
}
|
||||
$user->status = $status;
|
||||
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('pembida.senaraipembidakeseluruhan')->with('success','Pembida Berjaya Dikemaskini');
|
||||
|
||||
@@ -7,6 +7,7 @@ use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use PDF;
|
||||
|
||||
class PenggunaController extends Controller
|
||||
@@ -49,6 +50,8 @@ class PenggunaController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
|
||||
$user = User::where('id','=',$request->userid)->first();
|
||||
$allroles = Role::all()->pluck('name');
|
||||
@@ -64,6 +67,30 @@ class PenggunaController extends Controller
|
||||
}
|
||||
// dd($arraytaraf);
|
||||
$user->syncRoles($arraytaraf);
|
||||
|
||||
if($request->status == true)
|
||||
{
|
||||
$status = 'active';
|
||||
}
|
||||
else if($request->statusban == true)
|
||||
{
|
||||
$status = 'banned';
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = 'inactive';
|
||||
}
|
||||
|
||||
$user = User::where('id','=',$request->userid)->first();
|
||||
// dd($user);
|
||||
$user->email = $request->email;
|
||||
$user->notelbimbit = $request->notelbimbit;
|
||||
$user->nokp = $request->nokp;
|
||||
$user->updated_at = $currentdate;
|
||||
$user->status = $status;
|
||||
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('pengguna.index')
|
||||
->with('success','Kemaskini Berjaya');
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
<p>{{ $message }}</p>
|
||||
</div>
|
||||
@endif
|
||||
<form action="{{ route('pembida.update',$user->id) }}" method="POST" id="formkemaskini">
|
||||
<form action="{{ route('pembida.update') }}" method="POST" id="formkemaskini">
|
||||
@csrf
|
||||
<input type="hidden" value="{{$user->id}}" class="form-control" name="userid" id="userid" readonly>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputEmail4">Nama</label>
|
||||
@@ -32,13 +33,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex form-group">
|
||||
<div class="d-flex col-md-6">
|
||||
<div style="margin-right:2%;">
|
||||
<label for="status1">Status</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch" >
|
||||
<input type="checkbox" class="custom-control-input" id="customSwitch1" name="status" onchange="showstatus(this)">
|
||||
<label class="custom-control-label" for="customSwitch1" ><input data-status="{{ $user->status }}" type="text" id="txtstatus" style="border: none;" readonly></label>
|
||||
<input type="checkbox" class="custom-control-input" name="status" id="customSwitch1" onchange="showstatus(this)">
|
||||
<label class="custom-control-label" for="customSwitch1" data-status="{{ $user->status }}" id="txtstatus"></lable>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex col-md-6">
|
||||
<div style="margin-right:2%;">
|
||||
<label for="status1">Ban</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch" >
|
||||
<input type="checkbox" class="custom-control-input" style="background-color:red !important" name="statusban" id="customSwitch2" onchange="showban(this)">
|
||||
<label class="custom-control-label" for="customSwitch2" id="txtstatusban"></lable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<h4 class="col-md-3">Identity Card/Passport Picture</h4>
|
||||
@@ -52,8 +64,8 @@
|
||||
</div>
|
||||
<div class="text-right pt-4">
|
||||
<input type="hidden" name="userid" value="{{$user->id}}">
|
||||
<a href="{{url('pembida/senaraipembida')}}" class="btn btn-primary">Kembali</a>
|
||||
<button type="button" class="btn btn-success" data-toggle="modal" data-target=".bd-example-modal-sm" onclick="kemaskini()" >Kemaskini</button>
|
||||
<a href="{{url('pembida/senaraipembidakeseluruhan')}}" class="btn btn-primary">Kembali</a>
|
||||
<button type="button" class="btn btn-success" onclick="kemaskini()" >Kemaskini</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -61,27 +73,69 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var status = $('#txtstatus').data('status');
|
||||
|
||||
console.log(status);
|
||||
if(status == 'active'){
|
||||
$('#customSwitch1').prop('checked',true) ;
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
$('#txtstatus').text('Active');
|
||||
}
|
||||
else if(status == 'banned')
|
||||
{
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
$('#customSwitch2').prop('checked',true) ;
|
||||
$('#txtstatusban').text('Banned');
|
||||
}
|
||||
else{
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
function kemaskini() {
|
||||
// console.log($('#txtstatus').val());
|
||||
$("#formkemaskini").submit();
|
||||
}
|
||||
let status = $('#txtstatus').data('status');
|
||||
|
||||
console.log(status);
|
||||
if(status == 'active'){
|
||||
var value = $('#customSwitch1').prop('checked',true) ;
|
||||
$('#txtstatus').val('Active');
|
||||
}
|
||||
else{
|
||||
var value = $('#customSwitch1').prop('checked',false) ;
|
||||
$('#txtstatus').val('Inactive');
|
||||
function showban(e){
|
||||
var value = $(e).prop('checked') ;
|
||||
if( value == true){
|
||||
$('#txtstatus').text('Inactive');
|
||||
$('#txtstatusban').text('Banned');
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
}
|
||||
else{
|
||||
if(status == 'active'){
|
||||
$('#customSwitch1').prop('checked',true) ;
|
||||
$('#txtstatus').text('Active');
|
||||
$('#txtstatusban').text('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
}
|
||||
}
|
||||
function showstatus(e){
|
||||
var value = $(e).prop('checked') ;
|
||||
if( value == true){
|
||||
$('#txtstatus').val('Active');
|
||||
if( value == true)
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Active');
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
}
|
||||
else{
|
||||
$('#txtstatus').val('Inactive');
|
||||
if(status == 'banned'){
|
||||
$('#customSwitch2').prop('checked',true) ;
|
||||
$('#txtstatus').text('Inactive');
|
||||
$('#txtstatusban').text('Banned');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
}
|
||||
console.log(value);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
<button class="btn btn-success btn-sm hovernone-success" disabled>{{$user->status}}</button>
|
||||
@elseif ($user->status =='banned')
|
||||
<button class="btn btn-danger btn-sm hovernone-danger" disabled>{{$user->status}}</button>
|
||||
@elseif ($user->status == 'inactive')
|
||||
<button class="btn btn-danger btn-sm hovernone-danger" disabled>{{$user->status}}</button>
|
||||
@else ($user->status == null)
|
||||
Menunggu Pengesahan Operasi
|
||||
@endif
|
||||
|
||||
@@ -33,6 +33,28 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@if($user->user_type == 2)
|
||||
<div class="d-flex form-group">
|
||||
<div class="d-flex col-md-6">
|
||||
<div style="margin-right:2%;">
|
||||
<label for="status1">Status</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch" >
|
||||
<input type="checkbox" class="custom-control-input" name="status" id="customSwitch1" onchange="showstatus(this)">
|
||||
<label class="custom-control-label" for="customSwitch1" data-status="{{ $user->status }}" id="txtstatus"></lable>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex col-md-6">
|
||||
<div style="margin-right:2%;">
|
||||
<label for="status1">Ban</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch" >
|
||||
<input type="checkbox" class="custom-control-input" style="background-color:red !important" name="statusban" id="customSwitch2" onchange="showban(this)">
|
||||
<label class="custom-control-label" for="customSwitch2" id="txtstatusban"></lable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="text-right pt-4">
|
||||
<input type="hidden" name="userid" value="{{$user->id}}">
|
||||
<a href="{{url('pengguna/listpengguna')}}" class="btn btn-primary">Kembali</a>
|
||||
@@ -66,5 +88,71 @@
|
||||
});
|
||||
}
|
||||
|
||||
var status = $('#txtstatus').data('status');
|
||||
|
||||
console.log(status);
|
||||
if(status == 'active'){
|
||||
$('#customSwitch1').prop('checked',true) ;
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
$('#txtstatus').text('Active');
|
||||
}
|
||||
else if(status == 'banned')
|
||||
{
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
$('#customSwitch2').prop('checked',true) ;
|
||||
$('#txtstatusban').text('Banned');
|
||||
}
|
||||
else{
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
function kemaskini() {
|
||||
// console.log($('#txtstatus').val());
|
||||
$("#formkemaskini").submit();
|
||||
}
|
||||
|
||||
function showban(e){
|
||||
var value = $(e).prop('checked') ;
|
||||
if( value == true){
|
||||
$('#txtstatus').text('Inactive');
|
||||
$('#txtstatusban').text('Banned');
|
||||
$('#customSwitch1').prop('checked',false) ;
|
||||
}
|
||||
else{
|
||||
if(status == 'active'){
|
||||
$('#customSwitch1').prop('checked',true) ;
|
||||
$('#txtstatus').text('Active');
|
||||
$('#txtstatusban').text('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
}
|
||||
}
|
||||
function showstatus(e){
|
||||
var value = $(e).prop('checked') ;
|
||||
if( value == true)
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Active');
|
||||
$('#customSwitch2').prop('checked',false) ;
|
||||
}
|
||||
else{
|
||||
if(status == 'banned'){
|
||||
$('#customSwitch2').prop('checked',true) ;
|
||||
$('#txtstatus').text('Inactive');
|
||||
$('#txtstatusban').text('Banned');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#txtstatusban').text('');
|
||||
$('#txtstatus').text('Inactive');
|
||||
}
|
||||
}
|
||||
console.log(value);
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ Route::group(['middleware' => ['permission:pengesahanpembida'],'prefix'=>'pembid
|
||||
Route::get('/sahkanpembida/{id}',['as'=>'pembida.sah','uses'=>'PembidaController@sah']);
|
||||
Route::post('/reject',['as'=>'pembida.reject','uses'=>'PembidaController@reject']);
|
||||
Route::get('/kemaskini/{id}',['as'=>'pembida.kemaskini','uses'=>'PembidaController@kemaskini']);
|
||||
Route::post('/update/{id}',['as'=>'pembida.update','uses'=>'PembidaController@update']);
|
||||
Route::post('/update',['as'=>'pembida.update','uses'=>'PembidaController@update']);
|
||||
});
|
||||
//Operasi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user