VideoController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Services\LiquidRenderer;
  5. use App\Models\DistVideo ;
  6. class VideoController extends Controller
  7. {
  8. protected $liquidRenderer;
  9. public function __construct(LiquidRenderer $liquidRenderer)
  10. {
  11. $this->liquidRenderer = $liquidRenderer;
  12. }
  13. /**
  14. * Display a listing of the videos.
  15. *
  16. * @return \Illuminate\Http\Response
  17. */
  18. public function index()
  19. {
  20. $videos = DistVideo::paginate(10)->where('dist_id', getDistId()); // 每页显示10个视频
  21. return $this->liquidRenderer->render('videos.index', ['videos' => $videos]);
  22. }
  23. /**
  24. * Display the specified video.
  25. *
  26. * @param int $id
  27. * @return \Illuminate\Http\Response
  28. */
  29. public function show($id)
  30. {
  31. $video = DistVideo::findOrFail($id);
  32. // 构建导航数据 开始
  33. $breadcrumbs = [
  34. [
  35. 'url' => '/',
  36. 'name' => 'Home',
  37. ]
  38. ];
  39. $category=$video->distVideoCategory;
  40. $breadcrumbs[] = [
  41. 'url' => "/videos/{$category->name}",
  42. 'name' => $category->name,
  43. ];
  44. $breadcrumbs[] = [
  45. 'url' => '#',
  46. 'name' => $video->title,
  47. ];
  48. return $this->liquidRenderer->render('videos.show', ['video' => $video, 'breadcrumbs' => $breadcrumbs]);
  49. }
  50. }