vsmov-holy/resources/views/themeholy/index.blade.php
2026-05-20 11:47:28 +07:00

51 lines
1.8 KiB
PHP

@extends('themes::themeholy.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, $description, $relation, $field, $val, $sortKey, $alg, $limit, $link] = array_merge($list, ['Phim mới cập nhật', '', '', 'type', 'series', 'created_at', 'desc', 8, '/']);
try {
$data[] = [
'label' => $label,
'description' => $description,
'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(),
'link' => $link ?: '#',
];
} catch (\Exception $e) {
}
}
}
return $data;
});
@endphp
@section('content')
@include('themes::themeholy.inc.main_search')
<main class="page landing-page">
@foreach ($data as $item)
@include('themes::themeholy.inc.section_movies')
@endforeach
@include('themes::themeholy.inc.random_film')
</main>
@endsection
@push('scripts')
@endpush