- npm i vue-content-placeholders - add outline on pagination focus - refactorize actu card scss - fix actu card image url - increase actu to 119 in actu seeder - add ajax route to sitemap refresh onfig ignore route
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Actu;
|
|
use App\Models\Tag;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class ActuController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$tags = Tag::has('actus')->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());
|
|
}
|
|
)
|
|
);
|
|
}
|
|
}
|