فهرست منبع

ticket notify

1day2die 2 سال پیش
والد
کامیت
a0800509cb

+ 6 - 2
app/Http/Controllers/TicketsController.php

@@ -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);
     }

+ 7 - 0
database/seeders/Seeds/SettingsSeeder.php

@@ -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',
+        ]);
     }
 }

+ 17 - 0
themes/default/views/admin/settings/tabs/misc.blade.php

@@ -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>