A lot of things
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\XenForoHelpers;
|
||||
use App\Models\Entry;
|
||||
use App\Models\News;
|
||||
use App\Services\XenforoService;
|
||||
use Illuminate\Http\Request;
|
||||
class QueueController extends Controller
|
||||
@@ -14,7 +15,25 @@ class QueueController extends Controller
|
||||
->with(['authors', 'game.platform'])
|
||||
->orderByRaw("CASE WHEN state = 'pending' THEN 1 ELSE 0 END")
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
->get()
|
||||
->map(fn($item) => $item->setAttribute('queue_type', 'entry'));
|
||||
|
||||
$news = News::inQueue()
|
||||
->orderByRaw("CASE WHEN state = 'pending' THEN 1 ELSE 0 END")
|
||||
->orderBy('created_at', 'asc')
|
||||
->get()
|
||||
->map(fn($item) => $item->setAttribute('queue_type', 'news'));
|
||||
|
||||
$entries = $entries->concat($news)->sort(function($a, $b) {
|
||||
$aPending = $a->state === 'pending' ? 0 : 1;
|
||||
$bPending = $b->state === 'pending' ? 0 : 1;
|
||||
|
||||
if($aPending !== $bPending) {
|
||||
return $aPending <=> $bPending;
|
||||
}
|
||||
|
||||
return $a->created_at <=> $b->created_at;
|
||||
})->values();
|
||||
|
||||
return view('queue.index', compact('entries'));
|
||||
}
|
||||
@@ -25,24 +44,53 @@ class QueueController extends Controller
|
||||
|
||||
$entry->update(['staff_comment' => $request->input('comment')]);
|
||||
|
||||
return back()->with('success', 'Comment supdated');
|
||||
}
|
||||
|
||||
public function updateComment_news(Request $request, News $news)
|
||||
{
|
||||
$request->validate(['comment' => 'nullable|string|max:2000']);
|
||||
|
||||
$news->update(['staff_comment' => $request->input('comment')]);
|
||||
|
||||
return back()->with('success', 'Comment updated');
|
||||
}
|
||||
|
||||
public function approve(Request $request, Entry $entry)
|
||||
{
|
||||
// $entry->update(['state' => 'published']);
|
||||
$entry->update(['state' => 'published', 'created_at' => now()]);
|
||||
|
||||
XenForoHelpers::entryApproved($entry);
|
||||
|
||||
return back()->with('success', 'Entry approved');
|
||||
}
|
||||
|
||||
public function approve_news(Request $request, News $news)
|
||||
{
|
||||
$news->update(['state' => 'published', 'created_at' => now()]);
|
||||
|
||||
XenForoHelpers::entryApproved($news);
|
||||
|
||||
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() ]);
|
||||
|
||||
XenForoHelpers::entryRejected($entry);
|
||||
return back()->with('success', 'Entry rejected');
|
||||
}
|
||||
|
||||
public function reject_news(Request $request, News $news)
|
||||
{
|
||||
$request->validate(['reason' => 'nullable|string|max:2000']);
|
||||
|
||||
$news->update(['state' => 'rejected', 'staff_comment' => $request->input('reason'), 'rejected_at' => now() ]);
|
||||
|
||||
XenForoHelpers::entryRejected($news);
|
||||
return back()->with('success', 'Entry rejected');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user