ticket notify

This commit is contained in:
1day2die 2023-01-13 19:32:32 +01:00
parent e6b2afa1dc
commit a0800509cb
3 changed files with 30 additions and 2 deletions

View file

@ -59,9 +59,13 @@ class TicketsController extends Controller
);
$ticket->save();
$user = Auth::user();
$admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();
if(config('SETTINGS::TICKET:NOTIFY') == "all"){ $admin = User::where('role', 'admin')->orWhere('role', 'mod')->get();}
if(config('SETTINGS::TICKET:NOTIFY') == "admin"){ $admin = User::where('role', 'admin')->get();}
if(config('SETTINGS::TICKET:NOTIFY') == "moderator"){ $admin = User::where('role', 'mod')->get();}
$user->notify(new CreateNotification($ticket));
Notification::send($admin, new AdminCreateNotification($ticket, $user));
if(config('SETTINGS::TICKET:NOTIFY') != "none"){
Notification::send($admin, new AdminCreateNotification($ticket, $user));
}
return redirect()->route('ticket.index')->with('success', __('A ticket has been opened, ID: #').$ticket->ticket_id);
}

View file

@ -645,5 +645,12 @@ class SettingsSeeder extends Seeder
'type' => 'text',
'description' => 'SEO Description',
]);
Settings::firstOrCreate([
'key' => 'SETTINGS::TICKET:NOTIFY',
], [
'value' => 'all',
'type' => 'text',
'description' => 'Who will get a Email Notifcation on new Tickets',
]);
}
}

View file

@ -297,6 +297,23 @@
<label for="ticket_enabled">{{ __('Enable Ticketsystem') }} </label>
</div>
</div>
<div class="custom-control mb-3 p-0">
<label for="ticket_notify">{{ __('Notify on Ticket creation') }}:
<i data-toggle="popover" data-trigger="hover"
data-content="{{ __('Who will receive an E-Mail when a new Ticket is created') }}" class="fas fa-info-circle"></i>
</label>
<select id="ticket_notify" style="width:100%" class="custom-select" name="ticket_notify" required
autocomplete="off" @error('ticket_notify') is-invalid @enderror>
<option value="admin" @if (config('SETTINGS::TICKET:NOTIFY') == "admin") selected
@endif>{{ __("Admins") }}</option>
<option value="moderator" @if (config('SETTINGS::TICKET:NOTIFY') == "moderator") selected
@endif>{{ __("Moderators") }}</option>
<option value="all" @if (config('SETTINGS::TICKET:NOTIFY') == "all") selected
@endif>{{ __("Both") }}</option>
<option value="none" @if (config('SETTINGS::TICKET:NOTIFY') == "none") selected
@endif>{{ __("Disabled") }}</option>
</select>
</div>
</div>
</div>