ldc-groupe/app/View/Components/Front/News/IndexNewsComponent.php

67 lines
1.9 KiB
PHP

<?php
namespace App\View\Components\Front\News;
use Closure;
use App\Models\News;
use Illuminate\View\Component;
use Illuminate\Contracts\View\View;
use App\Helpers\BladeComponentHelper;
use Illuminate\Support\Facades\Route;
class IndexNewsComponent extends Component
{
public $postContainer;
/**
* Create a new component instance.
*/
public function __construct()
{
$bladeHelper = new BladeComponentHelper();
$locale = config('app.locale');
/**
* Cette section est à revoir mais c'est pour coller et être iso au site actuellement en prod
*/
$currentRoute = Route::currentRouteName();
$this->postContainer = [
'secondaryClass' => 'fw-container no-bottom-padding',
'tertiaryClass' => 'tagged-posts',
'slug' => 'news',
'category' => $locale === "fr" ? 'actualites' : 'news',
];
switch ($currentRoute) {
case 'front.news.index':
$this->postContainer['load_more'] = ucfirst(__('front.buttons.see_more_news'));
break;
case 'front.dynamic-pages.espace-presse':
$this->postContainer = array_merge($this->postContainer, [
'class' => 'fw-container no-top-padding',
'load_more' => ucfirst(__('front.buttons.see_more_docs')),
'type_button' => true
]);
break;
default:
$this->postContainer['load_more'] = ucfirst(__('front.buttons.see_more_news'));
break;
}
}
/**
* Get the view / contents that represent the component.
*
* @return View|Closure|string
*/
public function render(): View|Closure|string
{
return view('components.front.news.index-news-component', [
'postContainer' => $this->postContainer
]);
}
}