Skip to content

Commit 6fa2bb7

Browse files
committed
Merge branch 'home-page' of https://github.com/AllanKoder/ComputerScienceResources.com into home-page
2 parents a2492d4 + 09959e3 commit 6fa2bb7

3 files changed

Lines changed: 14 additions & 19 deletions

File tree

app/Http/Controllers/HomeController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
namespace App\Http\Controllers;
44

55
use App\Services\HomeStatisticsService;
6-
use Illuminate\Http\Request;
76
use Inertia\Inertia;
87

98
class HomeController extends Controller
109
{
1110
public function __construct(
1211
protected HomeStatisticsService $homeStatistics
13-
){}
12+
) {}
1413

1514
public function show()
1615
{

app/Services/HomeStatisticsService.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
namespace App\Services;
44

5-
use App\Models\ComputerScienceResource;
65
use Illuminate\Support\Collection;
76
use Illuminate\Support\Facades\DB;
87
use Illuminate\Support\Facades\Storage;
98

109
class HomeStatisticsService
1110
{
12-
public function __construct()
13-
{
14-
15-
}
11+
public function __construct() {}
1612

17-
function getPublicUrl(?string $path): ?string {
13+
public function getPublicUrl(?string $path): ?string
14+
{
1815
return $path ? Storage::disk('public')->url($path) : null;
1916
}
2017

@@ -24,7 +21,7 @@ private function resourceTop(): Collection
2421
->whereNotNull('image_path')
2522
->limit(10)
2623
->get()
27-
->map(fn($res) => [
24+
->map(fn ($res) => [
2825
'id' => $res->id,
2926
'image_url' => $this->getPublicUrl($res->image_path),
3027
]);
@@ -37,24 +34,22 @@ private function resourcesCount(): int
3734

3835
private function topTopics(): Collection
3936
{
40-
return DB::table('tag_frequencies')->where('type','topics_tags')
37+
return DB::table('tag_frequencies')->where('type', 'topics_tags')
4138
->orderByDesc('count')->limit(10)->get();
4239
}
4340

4441
private function topicsCount(): int
4542
{
46-
return DB::table('tag_frequencies')->where('type','topics_tags')->count();
43+
return DB::table('tag_frequencies')->where('type', 'topics_tags')->count();
4744
}
4845

49-
5046
public function getStatistics()
5147
{
52-
return array(
53-
"resources_top" => $this->resourceTop(),
54-
"resources_count" => $this->resourcesCount(),
55-
"topics_count" => $this->topicsCount(),
56-
"topics_top" => $this->topTopics()
57-
);
48+
return [
49+
'resources_top' => $this->resourceTop(),
50+
'resources_count' => $this->resourcesCount(),
51+
'topics_count' => $this->topicsCount(),
52+
'topics_top' => $this->topTopics(),
53+
];
5854
}
59-
6055
}

database/migrations/2025_09_06_223541_change_computer_science_resources_difficulty_to_set.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function down(): void
2626
DB::statement("
2727
UPDATE computer_science_resources
2828
SET difficulties = SUBSTRING_INDEX(difficulties, ',', 1)
29+
WHERE difficulties IS NOT NULL AND difficulties != ''
2930
");
3031

3132
DB::statement("

0 commit comments

Comments
 (0)