spelling. Reason updating.

This commit is contained in:
1Day 2022-08-12 11:59:20 +02:00
parent ce927744a2
commit 7e822be443
3 changed files with 35 additions and 12 deletions

View file

@ -95,7 +95,7 @@ class TicketsController extends Controller
switch ($tickets->status) { switch ($tickets->status) {
case 'Open': case 'Open':
$badgeColor = 'badge-success'; $badgeColor = 'badge-success';
break; break;
case 'Closed': case 'Closed':
$badgeColor = 'badge-danger'; $badgeColor = 'badge-danger';
break; break;
@ -126,7 +126,11 @@ class TicketsController extends Controller
$user = User::where('id', $request->user_id)->first(); $user = User::where('id', $request->user_id)->first();
$check = TicketBlacklist::where('user_id', $user->id)->first(); $check = TicketBlacklist::where('user_id', $user->id)->first();
if($check){ if($check){
return redirect()->back()->with('error', __('Target User already in blacklist')); $check->reason = $request->reason;
$check->status = "True";
$check->save();
return redirect()->back()->with('info', __('Target User already in blacklist. Reason updated'));
} }
TicketBlacklist::create(array( TicketBlacklist::create(array(
"user_id" => $user->id, "user_id" => $user->id,
@ -136,6 +140,7 @@ class TicketsController extends Controller
return redirect()->back()->with('success', __('Successfully add User to blacklist, User name: ' . $user->name)); return redirect()->back()->with('success', __('Successfully add User to blacklist, User name: ' . $user->name));
} }
public function blacklistDelete($id) { public function blacklistDelete($id) {
$blacklist = TicketBlacklist::where('id', $id)->first(); $blacklist = TicketBlacklist::where('id', $id)->first();
$blacklist->delete(); $blacklist->delete();
@ -166,14 +171,16 @@ class TicketsController extends Controller
->editColumn('status', function (TicketBlacklist $blacklist) { ->editColumn('status', function (TicketBlacklist $blacklist) {
switch ($blacklist->status) { switch ($blacklist->status) {
case 'True': case 'True':
$badgeColor = 'badge-success'; $text = "Blocked";
break;
default:
$badgeColor = 'badge-danger'; $badgeColor = 'badge-danger';
break; break;
default:
$text = "Unblocked";
$badgeColor = 'badge-success';
break;
} }
return '<span class="badge ' . $badgeColor . '">' . $blacklist->status . '</span>'; return '<span class="badge ' . $badgeColor . '">' . $text . '</span>';
}) })
->editColumn('reason', function (TicketBlacklist $blacklist) { ->editColumn('reason', function (TicketBlacklist $blacklist) {
return $blacklist->reason; return $blacklist->reason;
@ -198,5 +205,5 @@ class TicketsController extends Controller
->rawColumns(['user', 'status', 'reason', 'created_at', 'actions']) ->rawColumns(['user', 'status', 'reason', 'created_at', 'actions'])
->make(true); ->make(true);
} }
} }

View file

@ -245,8 +245,8 @@
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="{{ route('moderator.ticket.blacklist') }}" class="nav-link @if (Request::routeIs('moderator.ticket.blacklist')) active @endif"> <a href="{{ route('moderator.ticket.blacklist') }}" class="nav-link @if (Request::routeIs('moderator.ticket.blacklist')) active @endif">
<i class="nav-icon fas fa-user"></i> <i class="nav-icon fas fa-user-times"></i>
<p>{{ __('Black List') }}</p> <p>{{ __('Ticket Blacklist') }}</p>
</a> </a>
</li> </li>
@endif @endif
@ -467,6 +467,22 @@
} }
}) })
@endif @endif
@if (Session::has('info'))
Swal.fire({
icon: 'info',
title: '{{ Session::get('info') }}',
position: 'top-end',
showConfirmButton: false,
background: '#343a40',
toast: true,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
@endif
</script> </script>
</body> </body>

View file

@ -75,8 +75,8 @@
</select> </select>
</div> </div>
<div class="form-group "> <div class="form-group ">
<label for="reason" class="control-label">Reason</label> <label for="reason" class="control-label">{{__("Reason")}}</label>
<input id="reason" type="text" class="form-control" name="reason" placeholder="Input Some Reason"> <input id="reason" type="text" class="form-control" name="reason" placeholder="Input Some Reason" required>
</div> </div>
<button type="submit" class="btn btn-primary ticket-once"> <button type="submit" class="btn btn-primary ticket-once">
{{__('Submit')}} {{__('Submit')}}