myvideogamelist.com/app/Http/Controllers/PlatformController.php

101 lines
2.6 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Controllers;
use App\Models\Platform;
use Illuminate\Http\Request;
class PlatformController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// Direct the user to the page listing all platforms.
return view('pages.platforms.index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param string $platform
* @return \Illuminate\Http\Response
*/
public function show($platform)
{
// Fetch the platform.
if ($platform == 'Xbox_Series_X_S') {
$platform = Platform::where('name', 'Xbox Series X/S')->firstOrFail();
} elseif ($platform == 'Sega_Genesis_MegaDrive') {
$platform = Platform::where('name', 'Sega Genesis/MegaDrive')->firstOrFail();
} elseif ($platform == 'Meta_Oculus_Quest') {
$platform = Platform::where('name', 'Meta/Oculus Quest')->firstOrFail();
} elseif ($platform == 'Meta_Oculus_Quest_2') {
$platform = Platform::where('name', 'Meta/Oculus Quest 2')->firstOrFail();
} else {
$platform = Platform::where('name', str_replace('_', ' ', $platform))->firstOrFail();
}
// Direct the users to a page showing all the games for the specified platform.
return view('pages.platforms.show', compact('platform'));
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Platform $platform
* @return \Illuminate\Http\Response
*/
public function edit(Platform $platform)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Platform $platform
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Platform $platform)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Platform $platform
* @return \Illuminate\Http\Response
*/
public function destroy(Platform $platform)
{
//
}
}