Skip to content

Commit 715ac10

Browse files
committed
feat: [LAR-14] update communities links
1 parent 91c770b commit 715ac10

33 files changed

+370
-582
lines changed

app/Http/Controllers/DiscussionController.php

-29
This file was deleted.

app/Http/Controllers/FileUploadController.php

-39
This file was deleted.

app/Http/Controllers/HomeController.php

-61
This file was deleted.

app/Http/Controllers/SlackController.php

-39
This file was deleted.

app/Http/Requests/UpdatePasswordRequest.php renamed to app/Http/Requests/Api/UpdatePasswordRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Requests;
5+
namespace App\Http\Requests\Api;
66

77
use Illuminate\Foundation\Http\FormRequest;
88
use Illuminate\Validation\Rules\Password;

app/Http/Requests/UpdateProfileRequest.php renamed to app/Http/Requests/Api/UpdateProfileRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Requests;
5+
namespace App\Http\Requests\Api;
66

77
use Illuminate\Foundation\Http\FormRequest;
88
use Illuminate\Support\Facades\Auth;

app/Livewire/Pages/Forum/Index.php

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function reloadThreads(?int $channelId): void
6464
}
6565

6666
$this->resetPage();
67+
6768
$this->dispatch('render');
6869
}
6970

app/Livewire/Pages/Home.php

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Pages;
6+
7+
use App\Models\Article;
8+
use App\Models\Discussion;
9+
use App\Models\Plan;
10+
use App\Models\Thread;
11+
use Illuminate\Contracts\View\View;
12+
use Illuminate\Support\Collection;
13+
use Illuminate\Support\Facades\Cache;
14+
use Livewire\Component;
15+
16+
final class Home extends Component
17+
{
18+
public function render(): View
19+
{
20+
$ttl = now()->addDays(2);
21+
22+
// @phpstan-ignore-next-line
23+
seo()
24+
->description(__('pages/home.description'))
25+
->twitterDescription(__('pages/home.description'))
26+
->image(asset('/images/socialcard.png'))
27+
->twitterSite('laravelcm')
28+
->withUrl();
29+
30+
return view('livewire.pages.home', [
31+
'plans' => Cache::remember(
32+
key: 'plans',
33+
ttl: now()->addYear(),
34+
callback: fn () => Plan::query()->developer()->get()
35+
),
36+
'latestArticles' => Cache::remember(
37+
key: 'latestArticles',
38+
ttl: $ttl,
39+
callback: fn (): Collection => Article::with(['tags', 'user', 'user.transactions'])
40+
->published()
41+
->orderByDesc('sponsored_at')
42+
->orderByDesc('published_at')
43+
->orderByViews()
44+
->trending()
45+
->limit(4)
46+
->get()
47+
),
48+
'latestThreads' => Cache::remember(
49+
key: 'latestThreads',
50+
ttl: $ttl,
51+
callback: fn (): Collection => Thread::with(['user', 'user.transactions'])
52+
->whereNull('solution_reply_id')
53+
->whereBetween('threads.created_at', [now()->subMonths(3), now()])
54+
->inRandomOrder()
55+
->limit(4)
56+
->get()
57+
),
58+
'latestDiscussions' => Cache::remember(
59+
key: 'latestDiscussions',
60+
ttl: $ttl,
61+
callback: fn (): Collection => Discussion::with(['user', 'user.transactions'])
62+
->recent()
63+
->orderByViews()
64+
->limit(3)
65+
->get()
66+
),
67+
]);
68+
}
69+
}

app/Models/User.php

+16-14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Illuminate\Contracts\Auth\MustVerifyEmail;
1717
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
1818
use Illuminate\Database\Eloquent\Builder;
19+
use Illuminate\Database\Eloquent\Casts\Attribute;
1920
use Illuminate\Database\Eloquent\Collection;
2021
use Illuminate\Database\Eloquent\Factories\HasFactory;
2122
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -137,28 +138,29 @@ public function hasEnterprise(): bool
137138
return $this->enterprise !== null;
138139
}
139140

140-
public function getRolesLabelAttribute(): string
141+
public function rolesLabel(): Attribute
141142
{
142143
$roles = $this->getRoleNames()->toArray();
143144

144-
if (count($roles)) {
145-
return implode(', ', array_map(fn ($item) => ucwords($item), $roles));
146-
}
147-
148-
return 'N/A';
145+
return Attribute::get(fn () => count($roles)
146+
? implode(', ', array_map(fn ($item) => ucwords($item), $roles))
147+
: 'N/A'
148+
);
149149
}
150150

151-
public function getIsSponsorAttribute(): bool
151+
public function IsSponsor(): Attribute
152152
{
153-
if ($this->transactions_count > 0) {
154-
$transaction = $this->transactions()
155-
->where('status', TransactionStatus::COMPLETE->value)
156-
->first();
153+
return Attribute::get(function (): bool {
154+
if ($this->transactions_count > 0) {
155+
$transaction = $this->transactions()
156+
->where('status', TransactionStatus::COMPLETE->value)
157+
->first();
157158

158-
return (bool) $transaction;
159-
}
159+
return (bool) $transaction;
160+
}
160161

161-
return false;
162+
return false;
163+
});
162164
}
163165

164166
public function isAdmin(): bool

app/helpers.php

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use Carbon\Carbon;
56
use GrahamCampbell\Markdown\Facades\Markdown;
67
use Illuminate\Support\Facades\Auth;
78
use League\CommonMark\Output\RenderedContentInterface;
@@ -91,3 +92,15 @@ function route_to_reply_able(mixed $replyAble): string
9192
return route($routeName, $replyAble->slug);
9293
}
9394
}
95+
96+
if (! function_exists('isHolidayWeek')) {
97+
function isHolidayWeek(): bool
98+
{
99+
$now = Carbon::now();
100+
101+
$holidayStart = Carbon::createFromDate($now->year, 12, 21)->startOfDay();
102+
$holidayEnd = Carbon::createFromDate($now->year + 1, 1, 2)->endOfDay();
103+
104+
return $now->between($holidayStart, $holidayEnd);
105+
}
106+
}

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"qcod/laravel-gamify": "1.0.8",
3838
"ramsey/uuid": "^4.7.4",
3939
"sentry/sentry-laravel": "^4.10",
40-
"socialiteproviders/twitter": "^4.1.2",
4140
"spatie/laravel-data": "^4.10",
4241
"spatie/laravel-feed": "^4.2.1",
4342
"spatie/laravel-google-fonts": "^1.2.3",

0 commit comments

Comments
 (0)