A lot of things.

This commit is contained in:
2026-06-08 16:25:52 +02:00
parent 6f6d6b9b84
commit f529f74823
94 changed files with 9178 additions and 107 deletions

View File

@@ -0,0 +1,78 @@
<?php
namespace App\Http\Controllers;
use App\Jobs\RestoreXenForoCommentsThread;
use App\Models\Entry;
use Illuminate\Http\Request;
class ModCPController extends Controller
{
public function index()
{
$stats = [
'pending' => Entry::where('state', 'pending')->count(),
'locked' => Entry::where('state', 'locked')->count(),
'total' => Entry::count()
];
if( \Auth::user()->can('is-admin') ){
$stats['draft'] = Entry::where('state', 'draft')->count();
$stats['hidden'] = Entry::where('state', 'hidden')->count();
$stats['deleted'] = Entry::where('state', 'deleted')->count();
}
$recentDeleted = Entry::onlyTrashed()->latest('deleted_at')->limit(5)->get();
return view('modcp.index', compact('stats', 'recentDeleted'));
}
public function locked()
{
$entries = Entry::where('state', 'locked')
->with(['game.platform', 'authors'])
->latest()->paginate(25);
return view('modcp.entries', compact('entries'))->with('pageTitle', "Locked Entries")->with('state', 'locked');
}
public function draft()
{
$entries = Entry::where('state', 'draft')
->with(['game.platform', 'authors'])
->latest()->paginate(25);
return view('modcp.entries', compact('entries'))->with('pageTitle', "Draft Entries")->with('state', 'draft');
}
public function hidden()
{
$entries = Entry::where('state', 'hidden')
->with(['game.platform', 'authors'])
->latest()->paginate(25);
return view('modcp.entries', compact('entries'))->with('pageTitle', "Hidden Entries")->with('state', 'hidden');
}
public function deleted()
{
$entries = Entry::onlyTrashed()
->with(['game.platform', 'authors'])
->latest('deleted_at')->paginate(25);
return view('modcp.deleted', compact('entries'));
}
public function restore(Entry $entry)
{
$entry->restore();
RestoreXenForoCommentsThread::dispatch($entry->comments_thread_id);
$entry->update(['state' => 'draft']);
return back()->with('success', "Entry restored");
}
public function destroy(Entry $entry)
{
$entry->forceDelete();
return back()->with('success', "Entry permanently deleted");
}
}