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(); return view('front.actu.index', [ 'paginate' => 9, 'actus' => $actus, 'tags' => $tags ]); } 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()); } ) ); } }