调整视频详情页
This commit is contained in:
@@ -22,9 +22,9 @@ class IndexController extends AdminController
|
|||||||
$filter->column(1 / 2, function ($filter) {
|
$filter->column(1 / 2, function ($filter) {
|
||||||
$filter->like('title', '视频名称');
|
$filter->like('title', '视频名称');
|
||||||
$filter->like('category.id', '分类名称')
|
$filter->like('category.id', '分类名称')
|
||||||
->select(Category::selectOptions(function ($model) {
|
->select(Category::selectOptions(function ($model) {
|
||||||
return $model->where('status', 1)->where('type', Category::TYPE_ADVERT);
|
return $model->where('status', 1)->where('type', Category::TYPE_ADVERT);
|
||||||
}, '所有分类'));
|
}, '所有分类'));
|
||||||
});
|
});
|
||||||
$filter->disableIdFilter();
|
$filter->disableIdFilter();
|
||||||
});
|
});
|
||||||
@@ -35,60 +35,64 @@ class IndexController extends AdminController
|
|||||||
$grid->column('link', '视频地址')->downloadable();
|
$grid->column('link', '视频地址')->downloadable();
|
||||||
$grid->column('category.title', '分类名称');
|
$grid->column('category.title', '分类名称');
|
||||||
$grid->column('sort', '排序');
|
$grid->column('sort', '排序');
|
||||||
|
$grid->column('created_at', '发布时间');
|
||||||
|
|
||||||
return $grid;
|
return $grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a form builder.
|
* Make a form builder.
|
||||||
|
*
|
||||||
* @return Form
|
* @return Form
|
||||||
*/
|
*/
|
||||||
protected function form()
|
protected function form(): Form
|
||||||
{
|
{
|
||||||
$form = new Form(new Video());
|
$form = new Form(new Video());
|
||||||
|
|
||||||
$form->text('title', '视频名称')->required();
|
$form->text('title', '视频名称')->required();
|
||||||
|
|
||||||
$form->select('category_id', '所属分类')
|
$form->select('category_id', '所属分类')
|
||||||
->options(function () {
|
->options(function () {
|
||||||
return Category::query()
|
return Category::query()
|
||||||
->where('status', 1)
|
->where('status', 1)
|
||||||
->where('type', Category::TYPE_VIDEO)
|
->where('type', Category::TYPE_VIDEO)
|
||||||
->pluck('title', 'id');
|
->pluck('title', 'id');
|
||||||
})
|
})
|
||||||
->rules('required|min:1', [
|
->rules('required|min:1', [
|
||||||
'required' => '必须选择所属分类',
|
'required' => '必须选择所属分类',
|
||||||
'min' => '必须选择所属分类',
|
'min' => '必须选择所属分类',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->file('cover', '封面')
|
$form->file('cover', '封面')
|
||||||
->rules(function ($form) {
|
->rules(function ($form) {
|
||||||
if ($form->model()->cover != []) {
|
if ($form->model()->cover != []) {
|
||||||
return 'nullable|image';
|
return 'nullable|image';
|
||||||
} else {
|
} else {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->move('images/' . date('Y/m/d'))
|
->move('images/'.date('Y/m/d'))
|
||||||
->removable()
|
->removable()
|
||||||
->uniqueName();
|
->uniqueName();
|
||||||
|
|
||||||
$form->file('link', '视频')
|
$form->file('link', '视频')
|
||||||
->rules(function ($form) {
|
->rules(function ($form) {
|
||||||
if ($form->model()->cover != []) {
|
if ($form->model()->cover != []) {
|
||||||
return 'nullable|image';
|
return 'nullable|image';
|
||||||
} else {
|
} else {
|
||||||
return 'required';
|
return 'required';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->move('videos/' . date('Y/m/d'))
|
->move('videos/'.date('Y/m/d'))
|
||||||
->removable()
|
->removable()
|
||||||
->uniqueName();
|
->uniqueName();
|
||||||
|
|
||||||
$form->number('sort', '排序')
|
$form->number('sort', '排序')
|
||||||
->default(1)
|
->default(1)
|
||||||
->required()
|
->required()
|
||||||
->help('数字越大越靠前');
|
->help('数字越大越靠前');
|
||||||
|
|
||||||
|
$form->datetime('created_at', '发布时间');
|
||||||
|
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|||||||
33
app/Http/Controllers/VideoController.php
Normal file
33
app/Http/Controllers/VideoController.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Video;
|
||||||
|
|
||||||
|
class VideoController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: description
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2021/10/8 14:54
|
||||||
|
* @param \App\Models\Video $video
|
||||||
|
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function show(Video $video)
|
||||||
|
{
|
||||||
|
|
||||||
|
$parent = $category = $video->category;
|
||||||
|
|
||||||
|
if ($category->childrens->isEmpty() && $category->parent) {
|
||||||
|
$parent = $category->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return view('video.show', compact('video', 'parent', 'category'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,11 +12,25 @@ class Article extends Model
|
|||||||
|
|
||||||
use HasCovers, BelongsToCategory;
|
use HasCovers, BelongsToCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 获取详情地址
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2021/11/29 15:46
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getLinkAttribute(): string
|
public function getLinkAttribute(): string
|
||||||
{
|
{
|
||||||
return route('article.show', $this);
|
return route('article.show', $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 获取logo地址
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2021/11/29 15:46
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getLogoUrlAttribute(): string
|
public function getLogoUrlAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->parseImageUrl($this->logo);
|
return $this->parseImageUrl($this->logo);
|
||||||
@@ -24,6 +38,7 @@ class Article extends Model
|
|||||||
|
|
||||||
/***
|
/***
|
||||||
* Notes: 获取详情内图片
|
* Notes: 获取详情内图片
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2021/10/8 11:58
|
* @Date : 2021/10/8 11:58
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
@@ -41,6 +56,7 @@ class Article extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 获取一个默认图片
|
* Notes: 获取一个默认图片
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2020/6/3 16:29
|
* @Date : 2020/6/3 16:29
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
@@ -54,7 +70,7 @@ class Article extends Model
|
|||||||
if ($path) {
|
if ($path) {
|
||||||
$this->cover = str_replace("/storage", "", $path);
|
$this->cover = str_replace("/storage", "", $path);
|
||||||
$this->save();
|
$this->save();
|
||||||
$path = config('app.url') . $path;
|
$path = config('app.url').$path;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +82,7 @@ class Article extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 关联分类
|
* Notes: 关联分类
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2021/4/2 9:11
|
* @Date : 2021/4/2 9:11
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
@@ -73,7 +90,7 @@ class Article extends Model
|
|||||||
public function categories(): BelongsToMany
|
public function categories(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Category::class)
|
return $this->belongsToMany(Category::class)
|
||||||
->using(ArticleCategory::class);
|
->using(ArticleCategory::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function category(): BelongsTo
|
public function category(): BelongsTo
|
||||||
@@ -88,6 +105,7 @@ class Article extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: description
|
* Notes: description
|
||||||
|
*
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
* @Date : 2021/4/2 9:17
|
* @Date : 2021/4/2 9:17
|
||||||
* @param $query
|
* @param $query
|
||||||
@@ -96,15 +114,11 @@ class Article extends Model
|
|||||||
*/
|
*/
|
||||||
public function scopeByCategory($query, $ids)
|
public function scopeByCategory($query, $ids)
|
||||||
{
|
{
|
||||||
if (!is_array($ids)) {
|
if (! is_array($ids)) {
|
||||||
$ids = [$ids];
|
$ids = [$ids];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->whereIn('category_id', $ids);
|
return $query->whereIn('category_id', $ids);
|
||||||
//
|
|
||||||
// return $query->whereHas('categories', function ($q) use ($ids) {
|
|
||||||
// $q->whereIN('id', $ids);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,28 @@ class Video extends Model
|
|||||||
use HasCovers,
|
use HasCovers,
|
||||||
BelongsToCategory;
|
BelongsToCategory;
|
||||||
|
|
||||||
public function getlinkUrlAttribute(): string
|
/**
|
||||||
|
* Notes: 返回视频地址
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2021/11/29 15:43
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLinkUrlAttribute(): string
|
||||||
{
|
{
|
||||||
return $this->parseImageUrl($this->link);
|
return $this->parseImageUrl($this->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 返回视频详情地址
|
||||||
|
*
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date: 2021/11/29 15:43
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getShowLinkAttribute(): string
|
||||||
|
{
|
||||||
|
return route('video.show', $this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,21 +262,19 @@
|
|||||||
poster="{{ getVideoByCate(29,'cover_url') }}"
|
poster="{{ getVideoByCate(29,'cover_url') }}"
|
||||||
style="object-fit: fill;">
|
style="object-fit: fill;">
|
||||||
</video>
|
</video>
|
||||||
{{-- <img class="srSpread-video-icon"--}}
|
|
||||||
{{-- src="/assets/index/images/srIcon/srSpread_icon.png"/>--}}
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="srSpread-video-cont-title">
|
<div class="srSpread-video-cont-title"
|
||||||
|
data-href="{{ getVideoByCate(29,'show_link') }}">
|
||||||
{{ getVideoByCate(29,'title') }}
|
{{ getVideoByCate(29,'title') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-md-7">
|
<div class="col-xs-12 col-md-7">
|
||||||
<ul class="srSpread-list">
|
<ul class="srSpread-list">
|
||||||
@if(getVideosByCate(29,8))
|
@if(getVideosByCate(29,10))
|
||||||
@foreach(getVideosByCate(29,8) as $video)
|
@foreach(getVideosByCate(29,10) as $video)
|
||||||
@if($loop->iteration>1)
|
@if($loop->iteration>1)
|
||||||
<li data-href="" class="publicHover">
|
<li data-href="{{ $video->show_link }}" class="publicHover">
|
||||||
<div class="srRrends-list-cont">
|
<div class="srRrends-list-cont">
|
||||||
<div class="srRrends-list-text">
|
<div class="srRrends-list-text">
|
||||||
<div class="ce-nowrap-multi srRrends-list-name">
|
<div class="ce-nowrap-multi srRrends-list-name">
|
||||||
@@ -307,54 +305,34 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="srRrendText">
|
<div class="srRrendText">
|
||||||
@if (getArticlesBYCate(30,2)->isNotEmpty())
|
@if (getArticlesBYCate(30,2)->isNotEmpty())
|
||||||
<div class="ce-img srRrends-list-img">
|
<div class="ce-img srRrends-list-img"
|
||||||
<span style="background-image: url({{ getArticlesBYCate(30)->cover_url }});"></span>
|
data-href="{{ getOneArticleBYCate(30)->link }}">
|
||||||
|
<span style="background-image: url({{ getOneArticleBYCate(30)->cover_url }});"></span>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (getArticlesBYCate(30,2)->isNotEmpty())
|
@if (getArticlesBYCate(30,2)->isNotEmpty())
|
||||||
<ul class="srRrends-list">
|
<ul class="srRrends-list">
|
||||||
@foreach (getArticlesBYCate(30,2) as $info)
|
@foreach (getArticlesBYCate(30,2) as $info)
|
||||||
<li data-href="{{ $info->link }}" class="publicHover">
|
@if($loop->iteration>1)
|
||||||
<div class="srRrends-list-cont">
|
<li data-href="{{ $info->link }}" class="publicHover">
|
||||||
<div class="srRrends-list-text">
|
<div class="srRrends-list-cont">
|
||||||
<div class="ce-nowrap-multi srRrends-list-name">
|
<div class="srRrends-list-text">
|
||||||
{{ $info->title }}
|
<div class="ce-nowrap-multi srRrends-list-name">
|
||||||
|
{{ $info->title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="srRrends-list-time">
|
||||||
|
{{ $info->created_at->format('Y年m月d日') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="srRrends-list-time">
|
</li>
|
||||||
{{ $info->created_at->format('Y年m月d日') }}
|
@endif
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{-- <div class="srSpread-atlas">--}}
|
|
||||||
{{-- <div class="srSpread-atlas-title"--}}
|
|
||||||
{{-- style="background-image: url(/assets/index/images/srIcon/srSpread_back_00.png);">--}}
|
|
||||||
{{-- {{ getOneCategory(30,'title') }}--}}
|
|
||||||
{{-- </div>--}}
|
|
||||||
{{-- <ul class="srSpread-atlas-list">--}}
|
|
||||||
{{-- @if (getArticlesBYCate(30,2)->isNotEmpty())--}}
|
|
||||||
{{-- @foreach (getArticlesBYCate(30,2) as $info)--}}
|
|
||||||
{{-- <li data-href="{{ $info->link }}">--}}
|
|
||||||
{{-- <div class="ce-img srSpread-atlas-img">--}}
|
|
||||||
{{-- <span style="background-image: url({{ $info->cover_url }});"></span>--}}
|
|
||||||
{{-- </div>--}}
|
|
||||||
{{-- <div class="srSpread-atlas-name">{{ $info->title }}</div>--}}
|
|
||||||
{{-- </li>--}}
|
|
||||||
{{-- @endforeach--}}
|
|
||||||
{{-- @endif--}}
|
|
||||||
{{-- </ul>--}}
|
|
||||||
{{-- <div class="srSpread-atlas-more" data-href="{{ getOneCategory(30,'link') }}">--}}
|
|
||||||
{{-- <span>查看更多></span>--}}
|
|
||||||
{{-- </div>--}}
|
|
||||||
{{-- </div> --}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
36
resources/views/video/show.blade.php
Normal file
36
resources/views/video/show.blade.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', '视频详情')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<!-- 面包屑导航 -->
|
||||||
|
@include('category.navigation')
|
||||||
|
|
||||||
|
<!-- 内容 -->
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<!-- 左侧导航部分 -->
|
||||||
|
@include('category.left')
|
||||||
|
<!-- 右侧内容部分 -->
|
||||||
|
<div class="col-xs-12 col-md-9">
|
||||||
|
<div class="details-title">{{ $video->title }}</div>
|
||||||
|
<div class="details-time">
|
||||||
|
<span>{{ $video->created_at->format('Y-m-d') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="details-cont">
|
||||||
|
<video width="100%" height="100%" style="object-fit:fill" controls=""
|
||||||
|
src="{{ $video->link_url }}"
|
||||||
|
poster="{{ $video->cover_url }}">
|
||||||
|
</video>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- <div class="col-md-12 col-md-9">
|
||||||
|
<div class="no-searchCont">
|
||||||
|
<img src="/assets/index/images/org55.png"/>
|
||||||
|
<span>抱歉,暂无内容</span>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -15,7 +15,11 @@ Route::get('search', 'IndexController@search')->name('index.search');
|
|||||||
|
|
||||||
Route::get('articles/{article}', 'ArticleController@show')->name('article.show');
|
Route::get('articles/{article}', 'ArticleController@show')->name('article.show');
|
||||||
|
|
||||||
|
Route::get('videos/{video}', 'VideoController@show')->name('video.show');
|
||||||
|
|
||||||
Route::get('category/{category}', 'CategoryController@index')->name('category.show');
|
Route::get('category/{category}', 'CategoryController@index')->name('category.show');
|
||||||
|
|
||||||
|
|
||||||
//以下为导入数据
|
//以下为导入数据
|
||||||
Route::get('test/set_article_category', 'TestController@set_article_category');
|
Route::get('test/set_article_category', 'TestController@set_article_category');
|
||||||
Route::get('test/set_category', 'TestController@set_category');
|
Route::get('test/set_category', 'TestController@set_category');
|
||||||
|
|||||||
Reference in New Issue
Block a user