get(); $actus = Actu::where('status', true) ->with('tags:id') ->get(['id']) ->mapWithKeys(function ($actu) { return [ $actu->id => [ 'id' => $actu->id, 'tags' => $actu->tags->mapWithKeys(function ($tag) { return [$tag->id => $tag->id]; })->all() ] ]; })->all(); $generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null; $generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::actu())->first() : null; return view('front.actu.index', [ 'generalConfig' => $generalConfig, 'paginate' => 9, 'actus' => $actus, 'tags' => $tags ]); } public function view(Actu $actu) { $relatedActus = Actu::whereHas('tags', function ($q) use ($actu) { $q->whereIn('id', $actu->tags->pluck('id')); })->where('id', '!=', $actu->id)->whereStatus(true) ->inRandomOrder()->limit(3)->get(); $generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null; $generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::actu())->first() : null; return \view('front.actu.show', [ 'generalConfig' => $generalConfig, 'actu' => $actu, 'relatedActus' => $relatedActus ]); } public function renderActu(Actu $actu) { if (!request()->wantsJson()) { abort(404); } return response()->json( Cache::rememberForever( "ActuRendered_$actu->id", function () use ($actu) { return \base64_encode(\view( 'front.actu.card', ['actu' => $actu] )->render()); } ) ); } }