43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\Page;
|
|
use App\Models\Advice;
|
|
use App\Models\Post;
|
|
use App\Models\Product;
|
|
use App\Models\SeoDatum;
|
|
use App\Models\Text;
|
|
use App\Models\Title;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class NewsController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$page = Page::news();
|
|
$seoDatum = SeoDatum::where('page', $page)->first();
|
|
|
|
$advice_news = Advice::all()->first();
|
|
$texts_news = Text::where('page', Page::newsQuestions()->value)->get();
|
|
$title_newsPosts = Title::where('page', Page::newsPosts()->value)->first();
|
|
|
|
$posts = Post::where([
|
|
['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')],
|
|
['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')],
|
|
])
|
|
->orderBy('created_at', 'DESC')
|
|
->get();
|
|
|
|
$products_news = Product::where('is_news', true)->get();
|
|
|
|
return view('front.news', compact(
|
|
'seoDatum',
|
|
'advice_news',
|
|
'texts_news',
|
|
'title_newsPosts',
|
|
'posts',
|
|
'products_news'
|
|
));
|
|
}
|
|
}
|