-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathHomeController.php
66 lines (57 loc) · 2.27 KB
/
HomeController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\Article;
use App\Models\Discussion;
use App\Models\Premium\Plan;
use App\Models\Thread;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Cache;
final class HomeController extends Controller
{
public function __invoke(): View
{
$plans = Cache::remember('plans', now()->addYear(), function () {
return Plan::query()
->developer()
->get();
});
$latestArticles = Cache::remember('latestArticles', now()->addHour(), function () {
return Article::with(['tags', 'user', 'user.transactions'])
->published()
->orderByDesc('sponsored_at')
->orderByDesc('published_at')
->orderByViews()
->trending()
->limit(4)
->get();
});
$latestThreads = Cache::remember('latestThreads', now()->addHour(), function () {
return Thread::with(['user', 'user.transactions'])->whereNull('solution_reply_id')
->whereBetween('threads.created_at', [now()->subMonths(3), now()])
->inRandomOrder()
->limit(4)
->get();
});
$latestDiscussions = Cache::remember('latestDiscussions', now()->addHour(), function () {
return Discussion::with(['user', 'user.transactions'])
->recent()
->orderByViews()
->limit(3)
->get();
});
// @phpstan-ignore-next-line
seo()
->description('Laravel Cameroun est le portail de la communauté de développeurs PHP & Laravel au Cameroun, On partage, on apprend, on découvre et on construit une grande communauté.')
->twitterDescription('Laravel Cameroun est le portail de la communauté de développeurs PHP & Laravel au Cameroun, On partage, on apprend, on découvre et on construit une grande communauté.')
->image(asset('/images/socialcard.png'))
->twitterSite('laravelcm')
->withUrl();
return view('home', compact(
'latestArticles',
'latestThreads',
'latestDiscussions',
'plans'
));
}
}