...
This commit is contained in:
43
.Trash-1000/files/TagController.php
Normal file
43
.Trash-1000/files/TagController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Tag;
|
||||
use App\Models\Video;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('tags', ['tags' => Tag::all()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param string $normalized
|
||||
* @param int|null $id
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function showVideo($tagName)
|
||||
{
|
||||
// Retrieve the tag based on the provided tag name
|
||||
$tag = Tag::where('name', $tagName)->firstOrFail();
|
||||
|
||||
// Get a random video related to the tag
|
||||
$randomVideo = \App\Models\Video::getSingleRandom($tag);
|
||||
|
||||
// Pass the tag and the random video to your view
|
||||
return view('tag.show')->with(compact('tag', 'randomVideo'));
|
||||
}
|
||||
|
||||
// Define other CRUD operations for tags as needed.
|
||||
}
|
Reference in New Issue
Block a user