50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers;
|
||
|
|
|
||
|
|
use App\Helpers\XenForoHelpers;
|
||
|
|
use App\Models\Entry;
|
||
|
|
use App\Services\XenforoService;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
class QueueController extends Controller
|
||
|
|
{
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
$entries = Entry::inQueue()
|
||
|
|
->with(['authors', 'game.platform'])
|
||
|
|
->orderByRaw("CASE WHEN state = 'pending' THEN 1 ELSE 0 END")
|
||
|
|
->orderBy('created_at', 'asc')
|
||
|
|
->get();
|
||
|
|
|
||
|
|
return view('queue.index', compact('entries'));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function updateComment(Request $request, Entry $entry)
|
||
|
|
{
|
||
|
|
$request->validate(['comment' => 'nullable|string|max:2000']);
|
||
|
|
|
||
|
|
$entry->update(['staff_comment' => $request->input('comment')]);
|
||
|
|
|
||
|
|
return back()->with('success', 'Comment updated');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function approve(Request $request, Entry $entry)
|
||
|
|
{
|
||
|
|
// $entry->update(['state' => 'published']);
|
||
|
|
|
||
|
|
XenForoHelpers::entryApproved($entry);
|
||
|
|
|
||
|
|
return back()->with('success', 'Entry approved');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function reject(Request $request, Entry $entry)
|
||
|
|
{
|
||
|
|
$request->validate(['reason' => 'nullable|string|max:2000']);
|
||
|
|
|
||
|
|
$entry->update(['state' => 'rejected', 'staff_comment' => $request->input('reason'), 'rejected_at' => now() ]);
|
||
|
|
|
||
|
|
return back()->with('success', 'Entry rejected');
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|