diff --git a/app/Http/Controllers/ActuController.php b/app/Http/Controllers/ActuController.php
index 7ad8d5e6..36bdab9a 100644
--- a/app/Http/Controllers/ActuController.php
+++ b/app/Http/Controllers/ActuController.php
@@ -5,26 +5,36 @@ namespace App\Http\Controllers;
use App\Enums\GeneralConfigType;
use App\Models\Actu;
use App\Models\Tag;
+use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Cache;
class ActuController extends Controller
{
+ /**
+ * Display a listing of the resource.
+ *
+ * @return \Illuminate\Contracts\View\View
+ */
public function index()
{
- $tags = Tag::has('actus')->get();
- $actus = Actu::where('status', true)
+ /** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Tag> */
+ $tags = Tag::query()->whereHas('actus', function (Builder $q) {
+ $q->where('status', true);
+ })->get();
+ /** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Actu> */
+ $actus = Actu::query()->where('status', true)
->with('tags:id')
+ ->orderBy('created_at', 'DESC')
->get(['id'])
- ->mapWithKeys(function ($actu) {
+ ->map(function ($actu) {
return [
- $actu->id => [
- 'id' => $actu->id,
- 'tags' => $actu->tags->mapWithKeys(function ($tag) {
- return [$tag->id => $tag->id];
- })->all()
- ]
+ 'id' => $actu->id,
+ 'tags' => $actu->tags->map(function ($tag) {
+ return $tag->id;
+ })->all()
];
})->all();
+
$generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null;
$generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::actu())->first() : null;
return view('front.actu.index', [
@@ -35,6 +45,12 @@ class ActuController extends Controller
]);
}
+ /**
+ * Display a news
+ *
+ * @param \App\Models\Actu $actu
+ * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
+ */
public function view(Actu $actu)
{
$relatedActus = Actu::whereHas('tags', function ($q) use ($actu) {
@@ -50,6 +66,12 @@ class ActuController extends Controller
]);
}
+ /**
+ * Render a news for JS usage (ajax)
+ *
+ * @param \App\Models\Actu $actu
+ * @return string Base64 rendered view.
+ */
public function renderActu(Actu $actu)
{
if (!request()->wantsJson()) {
diff --git a/resources/js/components/fo/ActuPaginatorComponent.vue b/resources/js/components/fo/ActuPaginatorComponent.vue
index b1170cf4..adc916da 100644
--- a/resources/js/components/fo/ActuPaginatorComponent.vue
+++ b/resources/js/components/fo/ActuPaginatorComponent.vue
@@ -8,18 +8,18 @@
-