Auf der Startseite wurden Veranstaltungen angezeigt, obwohl sie für die Veröffentlichung deaktiviert waren
82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Models\Tag;
|
|
use App\Models\Post;
|
|
use \Carbon\Carbon;
|
|
|
|
class LandingController extends ExtendedController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$model = Post::select('*')
|
|
// ->withImages()
|
|
// Einsätze und Berichte werden nur angezeigt wenn sie von heute oder älter sind
|
|
->where(function($query){
|
|
$query->whereIn('type', ['einsatz', 'bericht'])
|
|
->where('datetime', '<=', Carbon::now()->addWeeks(2))
|
|
->isPublished();
|
|
})
|
|
// Veranstaltungen werden nur angezeigt, wenn sie zwischen heute und 2 Wochen in der Zukunft sind
|
|
->orWhere(function($query){
|
|
$query->whereIn('type', ['veranstaltung'])
|
|
->whereBetween('datetime', [Carbon::now(), Carbon::now()->addWeeks(2)])
|
|
->isPublished();
|
|
})
|
|
// ->whereIn('type', ['einsatz', 'veranstaltung', 'bericht'])
|
|
// ->where('datetime', '<=', Carbon::now()->addWeeks(2))
|
|
->orderBy('datetime', 'DESC')
|
|
->limit(9)
|
|
->get();
|
|
|
|
$articles = Post::select('title', 'type', 'slug')
|
|
->isType('bericht')
|
|
->isPublished()
|
|
->withoutImages()
|
|
->where('datetime', '<', Carbon::now()->addWeeks(2))
|
|
->orderBy('datetime', 'DESC')
|
|
->limit(4)
|
|
->get();
|
|
|
|
$operations = Post::select('title', 'type', 'slug')
|
|
->isType('einsatz')
|
|
->isPublished()
|
|
->withoutImages()
|
|
->where('datetime', '<', Carbon::now()->addWeeks(2))
|
|
->orderBy('datetime', 'DESC')
|
|
->limit(4)
|
|
->get();
|
|
|
|
$events = Post::select('title', 'type', 'slug')
|
|
->isType('veranstaltung')
|
|
->isPublished()
|
|
->withoutImages()
|
|
->where('datetime', '<', Carbon::now())//->addWeeks(2))
|
|
->orderBy('datetime', 'DESC')
|
|
->limit(4)
|
|
->get();
|
|
|
|
$sidebar = [
|
|
$this->createSidebarLinks($articles, __('models.current articles')),
|
|
$this->createSidebarLinks($operations, __('models.current operations')),
|
|
$this->createSidebarLinks($events, __('models.current events')),
|
|
];
|
|
|
|
$view = view('inc.views.cardPreviewContainer');
|
|
$view->with('config', array());
|
|
$view->with('models', $model);
|
|
// $view->with('sidebar', $sidebar);
|
|
$view->with('url', $this->route);
|
|
|
|
return $view;
|
|
}
|
|
}
|