podcastartgenerator/site/app/Http/Controllers/EpisodeController.php

108 lines
2.6 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use App\Models\Podcast;
use App\Models\Artworks;
use App\Models\Episode;
class EpisodeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function 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 \App\Models\Episode $episode
* @return \Illuminate\Http\Response
*/
public function show(Request $request, $podcast_slug, $slug)
{
$user = auth()->user();
$episode = Episode::where('slug', $slug)
->with('artworks')
->with('artwork')
->with('podcast')
->whereNotNull('artworks.approved_by')
->firstOrFail();
$podcasts = Podcast::where('published', true)->with('episodes', function ($query) {
$query->orderBy('episode_number', 'desc');
$query->where('published', true);
$query->take(10);
})->get();
return view('episodes.episode', [
'user' => $user,
'pageTitle' => '"' . $episode->title . '" ' . $episode->podcast->name . ' Episode ' . number_format($episode->episode_number + 0),
'podcast' => $episode->podcast,
'episode' => $episode,
'podcasts' => $podcasts,
]);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Episode $episode
* @return \Illuminate\Http\Response
*/
public function edit(Episode $episode)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Episode $episode
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Episode $episode)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Episode $episode
* @return \Illuminate\Http\Response
*/
public function destroy(Episode $episode)
{
//
}
}