ldc-doux/app/Http/Controllers/NewsController.php

37 lines
1 KiB
PHP
Raw Normal View History

2022-05-12 16:03:40 +02:00
<?php
namespace App\Http\Controllers;
use App\Enums\Page;
2022-05-13 13:19:40 +02:00
use App\Models\Advice;
use App\Models\Post;
use App\Models\Product;
2022-05-12 16:03:40 +02:00
use App\Models\SeoDatum;
2022-05-13 13:19:40 +02:00
use App\Models\Text;
use App\Models\Title;
use Illuminate\Support\Carbon;
2022-05-12 16:03:40 +02:00
class NewsController extends Controller
{
public function index()
{
$page = Page::news();
$seoDatum = SeoDatum::where('page',$page)->first();
2022-05-13 13:19:40 +02:00
$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'));
2022-05-12 16:03:40 +02:00
}
}