56 lines
2.4 KiB
PHP
56 lines
2.4 KiB
PHP
@extends('themes::themerrdyw.layout')
|
|
|
|
@php
|
|
use VsMov\Core\Models\Movie;
|
|
$data = Cache::remember('site.movies.latest', setting('site_cache_ttl', 5 * 60), function () {
|
|
$lists = preg_split('/[\n\r]+/', get_theme_option('latest'));
|
|
$data = [];
|
|
foreach ($lists as $list) {
|
|
if (trim($list)) {
|
|
$list = explode('|', $list);
|
|
[$label, $relation, $field, $val, $sortKey, $alg, $limit, $link, $show_template] = array_merge($list, ['Phim mới cập nhật', '', '', 'type', 'series', 'created_at', 'desc', 8, '/', 'section_thumb']);
|
|
try {
|
|
$data[] = [
|
|
'label' => $label,
|
|
'show_template' => $show_template,
|
|
'data' => Movie::when($relation, function ($query) use ($relation, $field, $val) {
|
|
$query->whereHas($relation, function ($rel) use ($field, $val) {
|
|
$rel->where($field, $val);
|
|
});
|
|
})
|
|
->when(!$relation, function ($query) use ($field, $val) {
|
|
$query->where($field, $val);
|
|
})
|
|
->orderBy($sortKey, $alg)
|
|
->limit($limit)
|
|
->get(),
|
|
'topview' => Movie::when($relation, function ($query) use ($relation, $field, $val) {
|
|
$query->whereHas($relation, function ($rel) use ($field, $val) {
|
|
$rel->where($field, $val);
|
|
});
|
|
})
|
|
->when(!$relation, function ($query) use ($field, $val) {
|
|
$query->where($field, $val);
|
|
})
|
|
->orderBy('view_total', 'desc')
|
|
->limit(10)
|
|
->get(),
|
|
'link' => $link ?: '#',
|
|
];
|
|
} catch (\Exception $e) {
|
|
}
|
|
}
|
|
}
|
|
return $data;
|
|
});
|
|
@endphp
|
|
@section('content')
|
|
<div class="row">
|
|
<div class="stui-pannel stui-pannel-bg clearfix">
|
|
@foreach($data as $item)
|
|
@include("themes::themerrdyw.inc.section." . $item["show_template"])
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endsection
|