Club System
This commit is contained in:
@@ -4,31 +4,47 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Helpers\EntryHelpers;
|
||||
use App\Models\Entry;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EntryController extends Controller
|
||||
{
|
||||
|
||||
private const SECTION_TYPES = [ 'translations', 'romhacks', 'homebrew', 'utilities', 'documents', 'lua-scripts', 'tutorials' ];
|
||||
private const SECTION_TYPES = ['translations', 'romhacks', 'homebrew', 'utilities', 'documents', 'lua-scripts', 'tutorials'];
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
|
||||
return view('entries.index');
|
||||
}
|
||||
|
||||
public function show(string $section, Entry $entry): View
|
||||
{
|
||||
if( ! in_array($section, self::SECTION_TYPES) )
|
||||
if (!in_array($section, self::SECTION_TYPES))
|
||||
abort(404);
|
||||
|
||||
if( $entry->type !== $section )
|
||||
if ($entry->type !== $section)
|
||||
abort(404);
|
||||
|
||||
$comments = EntryHelpers::getLatestComments( $entry );
|
||||
Gate::authorize('viewAny', $entry);
|
||||
|
||||
return view('entries.show', compact('entry', 'section', 'comments' ) );
|
||||
// Permissions.
|
||||
$entryPolicy = match ($entry->state) {
|
||||
'pending' => 'viewPending',
|
||||
'draft' => 'viewDraft',
|
||||
'rejected' => 'viewRejected',
|
||||
'hidden' => 'viewHidden',
|
||||
'locked' => 'viewLocked',
|
||||
'published' => null,
|
||||
'default' => null
|
||||
};
|
||||
|
||||
if ($entryPolicy)
|
||||
Gate::authorize($entryPolicy, $entry);
|
||||
|
||||
$comments = EntryHelpers::getLatestComments($entry);
|
||||
|
||||
return view('entries.show', compact('entry', 'section', 'comments'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ class FileServerController extends Controller {
|
||||
'filepath' => $data['file_path'],
|
||||
'filesize' => $data['file']['size'],
|
||||
'favorite_server' => $data['favorite_server'],
|
||||
'favorite_at' => time()
|
||||
'favorite_at' => time(),
|
||||
'state' => 'public'
|
||||
], now()->addHours(2) );
|
||||
|
||||
$data['finished'] = true;
|
||||
|
||||
49
app/Http/Controllers/QueueController.php
Normal file
49
app/Http/Controllers/QueueController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user