-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHomeController.php
More file actions
56 lines (48 loc) · 1.51 KB
/
Copy pathHomeController.php
File metadata and controls
56 lines (48 loc) · 1.51 KB
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
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Enums\ProjectStatus;
use App\Http\Resources\Articles\ArticleCardResource;
use App\Http\Resources\BCRProjectCardResource;
use App\Http\Resources\ProjectCardResource;
use App\Models\Article;
use App\Models\BCRProject;
use App\Models\Organization;
use App\Models\Project;
use Inertia\Inertia;
class HomeController extends Controller
{
public function index()
{
return Inertia::render('Public/Home', [
'projects_count' => Project::query()
->whereIsPublished()
->count(),
'organizations_count' => Organization::query()
->isApproved()
->count(),
'projects' => ProjectCardResource::collection(
Project::whereIsOpen()
->whereHasValidDates('start','end')
->latest()
->limit(12)
->get()
),
'bcr_projects' => BCRProjectCardResource::collection(
BCRProject::query()
->where('status', ProjectStatus::approved)
->whereHasValidDates()
->latest()
->with('county')
->limit(12)
->get()
),
'articles' => ArticleCardResource::collection(
Article::query()
->latest()
->limit(3)
->get()
),
]);
}
}