37 lines
844 B
PHP
37 lines
844 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Entry;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class EntryController extends Controller
|
|
{
|
|
|
|
private const SECTION_TYPES = [ 'translations', 'romhacks', 'homebrew', 'utilities', 'documents', 'lua-scripts', 'tutorials' ];
|
|
|
|
public function index(): View
|
|
{
|
|
$entries = Entry::published()
|
|
->with(['game.platform', 'platform'])
|
|
->latest('published_at')
|
|
->paginate(30);
|
|
|
|
return view('entries.index', compact('entries'));
|
|
}
|
|
|
|
public function show(string $section, Entry $entry): View
|
|
{
|
|
if( ! in_array($section, self::SECTION_TYPES) )
|
|
abort(404);
|
|
|
|
if( $entry->type !== $section )
|
|
abort(404);
|
|
|
|
return view('entries.show', compact('entry', 'section'));
|
|
|
|
}
|
|
|
|
}
|