ticket notify permission

This commit is contained in:
1day2die 2023-05-05 12:29:28 +02:00
parent 0ca052a2ba
commit d41d0a6e2d
3 changed files with 12 additions and 25 deletions

View file

@ -58,17 +58,13 @@ class TicketsController extends Controller
);
$ticket->save();
$user = Auth::user();
switch ($ticket_settings->notify) {
case 'all':
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
Notification::send($admin, new AdminCreateNotification($ticket, $user));
case 'admin':
$admin = User::where('role', 'admin')->get();
Notification::send($admin, new AdminCreateNotification($ticket, $user));
case 'moderator':
$admin = User::where('role', 'mod')->get();
Notification::send($admin, new AdminCreateNotification($ticket, $user));
$staffNotify = User::permission('admin.tickets.get_notification')->get();
foreach($staffNotify as $staff){
Notification::send($staff, new AdminCreateNotification($ticket, $user));
}
$user->notify(new CreateNotification($ticket));
return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #') . $ticket->ticket_id);
@ -112,9 +108,12 @@ class TicketsController extends Controller
'message' => $request->input('message'),
]);
$user = Auth::user();
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
$newmessage = $request->input('ticketcomment');
Notification::send($admin, new AdminReplyNotification($ticket, $user, $newmessage));
$staffNotify = User::permission('admin.tickets.get_notification')->get();
foreach($staffNotify as $staff){
Notification::send($staff, new AdminReplyNotification($ticket, $user, $newmessage));
}
return redirect()->back()->with('success', __('Your comment has been submitted'));
}

View file

@ -7,7 +7,6 @@ use Spatie\LaravelSettings\Settings;
class TicketSettings extends Settings
{
public bool $enabled;
public string $notify;
public static function group(): string
{
@ -22,7 +21,6 @@ class TicketSettings extends Settings
{
return [
'enabled' => 'nullable|boolean',
'notify' => 'nullable|string',
];
}
@ -40,17 +38,6 @@ class TicketSettings extends Settings
'type' => 'boolean',
'description' => 'Enable or disable the ticket system.',
],
'notify' => [
'label' => 'Notify',
'type' => 'select',
'description' => 'Who will receive an E-Mail when a new Ticket is created.',
'options' => [
'admin' => 'Admins',
'moderator' => 'Moderators',
'all' => 'Admins and Moderators',
'none' => 'Nobody',
],
],
];
}
}

View file

@ -15,6 +15,7 @@ return [
'admin.ticket.read',
'admin.tickets.write',
'admin.tickets.get_notification',
'admin.ticket_blacklist.read',
'admin.ticket_blacklist.write',