You've already forked Atomcms-edit
f29ba72591
Security:
- Replace unescaped {!! !!} with Purify::clean() in 15+ Blade templates (XSS)
- Add rate limiting to register (3/hr), upload (10/min), SSE (6/min)
- Add max:5000 validation on article comments
- Remove duplicate exception handler callback
Hardcoded paths:
- Replace ~44 /var/www/ hardcoded paths with env() configs
- CatalogService (13), AutoDetectService (18), Commandocentrum (11), AppServiceProvider (2)
Performance:
- Add 10 missing database indexes (radio_song_requests, help_center_tickets, etc.)
- Replace Cache::flush() with targeted Cache::forget() in RadioSettings
- Cache getCachedCategories() in TicketController (N+1 fix)
- Remove redundant top-3 leaderboard query
Bug fixes:
- Fix undefined $enabled variable → $isOnline in radio index view
- Add getAvatarAttribute() accessor for non-existent avatar column
- Fix User::guilds() from wrong HasMany to HasManyThrough
Code quality:
- Replace file_get_contents with Http::timeout(10) in TraxService
- Remove commented Echo/Pusher boilerplate in bootstrap.js
- Remove TODO/FIXME comments from logo-generator templates
- Replace hardcoded Turnstile CDN URL with config()
- Restore QUEUE_CONNECTION=redis in .env.example files
147 lines
4.7 KiB
PHP
Executable File
147 lines
4.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Help;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\WebsiteTicketFormRequest;
|
|
use App\Models\Help\WebsiteHelpCenterCategory;
|
|
use App\Models\Help\WebsiteHelpCenterTicket;
|
|
use App\Models\Help\WebsiteHelpCenterTicketReply;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\View\View;
|
|
|
|
class TicketController extends Controller
|
|
{
|
|
public function index(): View|RedirectResponse
|
|
{
|
|
if (! hasPermission('manage_website_tickets')) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You cannot access this page'),
|
|
]);
|
|
}
|
|
|
|
return view('help-center.tickets.index', [
|
|
'tickets' => WebsiteHelpCenterTicket::orderBy('open')->with('user:id,username')->paginate(15),
|
|
]);
|
|
}
|
|
|
|
private function getCachedCategories(): \Illuminate\Database\Eloquent\Collection
|
|
{
|
|
return Cache::remember('help_categories', 3600, fn () => WebsiteHelpCenterCategory::get());
|
|
}
|
|
|
|
public function create(): View
|
|
{
|
|
return view('help-center.tickets.create', [
|
|
'categories' => $this->getCachedCategories(),
|
|
'openTickets' => WebsiteHelpCenterTicket::where('open', true)->where('user_id', Auth::id())->get(),
|
|
]);
|
|
}
|
|
|
|
public function store(WebsiteTicketFormRequest $request): RedirectResponse
|
|
{
|
|
Auth::user()->tickets()->create($request->validated());
|
|
|
|
Cache::forget('help_categories');
|
|
|
|
return redirect()->back()->with('success', __('Ticket submitted!'));
|
|
}
|
|
|
|
public function edit(WebsiteHelpCenterTicket $ticket): View|RedirectResponse
|
|
{
|
|
if (! $ticket->canManageTicket()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You cannot manage others tickets.'),
|
|
]);
|
|
}
|
|
|
|
$ticket->load([
|
|
'user:id,username,look',
|
|
'category',
|
|
'replies.user:id,username,look',
|
|
]);
|
|
|
|
return view('help-center.tickets.edit', [
|
|
'ticket' => $ticket,
|
|
'categories' => $this->getCachedCategories(),
|
|
'openTickets' => WebsiteHelpCenterTicket::where('open', true)->where('id', '!=', $ticket->id)->where('user_id', Auth::id())->get(),
|
|
]);
|
|
}
|
|
|
|
public function update(WebsiteHelpCenterTicket $ticket, WebsiteTicketFormRequest $request): RedirectResponse
|
|
{
|
|
if (! $ticket->canManageTicket()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You cannot manage others tickets.'),
|
|
]);
|
|
}
|
|
|
|
$ticket->update($request->validated());
|
|
|
|
Cache::forget('help_categories');
|
|
|
|
return to_route('help-center.ticket.show', $ticket)->with('success', __('Ticket updated!'));
|
|
}
|
|
|
|
public function show(WebsiteHelpCenterTicket $ticket): View|RedirectResponse
|
|
{
|
|
if (! $ticket->canManageTicket()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You cannot view others tickets.'),
|
|
]);
|
|
}
|
|
|
|
$ticket->load([
|
|
'user:id,username,look',
|
|
'category',
|
|
'replies.user:id,username,look',
|
|
]);
|
|
|
|
return view('help-center.tickets.show', [
|
|
'ticket' => $ticket,
|
|
'openTickets' => WebsiteHelpCenterTicket::where('open', true)->where('id', '!=', $ticket->id)->where('user_id', Auth::id())->get(),
|
|
]);
|
|
}
|
|
|
|
public function destroy(WebsiteHelpCenterTicket $ticket): RedirectResponse
|
|
{
|
|
if (! $ticket->canDeleteTicket()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You cannot delete others tickets.'),
|
|
]);
|
|
}
|
|
|
|
$ticket->delete();
|
|
|
|
return to_route('me.show')->with('success', __('The ticket has been deleted!'));
|
|
}
|
|
|
|
public function destroyReply(WebsiteHelpCenterTicketReply $reply): RedirectResponse
|
|
{
|
|
if (! $reply->canDeleteReply()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You do not have permission to delete this reply.'),
|
|
]);
|
|
}
|
|
|
|
$reply->delete();
|
|
|
|
return redirect()->back()->with('success', __('The reply has been deleted!'));
|
|
}
|
|
|
|
public function toggleTicketStatus(WebsiteHelpCenterTicket $ticket): RedirectResponse
|
|
{
|
|
if (! $ticket->canManageTicket()) {
|
|
return redirect()->back()->with([
|
|
'message' => __('You manage others tickets.'),
|
|
]);
|
|
}
|
|
|
|
$ticket->open ? $ticket->update(['open' => false]) : $ticket->update(['open' => true]);
|
|
|
|
return redirect()->back()->with('success', __('The ticket status has been changed!'));
|
|
}
|
|
}
|