Skip to content

Commit a62a9d5

Browse files
Feature/lar 102 user profile (#237)
2 parents 182c3fd + 2b8aec6 commit a62a9d5

File tree

131 files changed

+1994
-4852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1994
-4852
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
npm-debug.log
55
yarn-error.log
66
yarn.lock
7+
pnpm-lock.yml
78
/vendor
89
composer.phar
910

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Actions\User;
6+
7+
use App\Events\EmailAddressWasChanged;
8+
use App\Models\User;
9+
10+
final class UpdateUserProfileAction
11+
{
12+
public function execute(array $data, User $user, string $currentUserEmail): User
13+
{
14+
$user->update($data);
15+
16+
if ($user->email !== $currentUserEmail) {
17+
$user->email_verified_at = null;
18+
$user->save();
19+
20+
event(new EmailAddressWasChanged($user));
21+
}
22+
23+
return $user;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Console\Commands;
6+
7+
use App\Models\User;
8+
use App\Traits\FormatSocialAccount;
9+
use Illuminate\Console\Command;
10+
11+
final class UpdateUserSocialAccount extends Command
12+
{
13+
use FormatSocialAccount;
14+
15+
protected $signature = 'lcm:update-user-social-account';
16+
17+
protected $description = 'Update user social account to normal format';
18+
19+
public function handle(): void
20+
{
21+
$this->info('Start updating users social account...');
22+
23+
foreach (User::verifiedUsers()->get() as $user) {
24+
$this->info('Updating '.$user->username.'...');
25+
$user->update([
26+
'twitter_profile' => $this->formatTwitterHandle($user->twitter_profile),
27+
'github_profile' => $this->formatGithubHandle($user->github_profile),
28+
'linkedin_profile' => $this->formatLinkedinHandle($user->linkedin_profile),
29+
]);
30+
$this->line('');
31+
}
32+
33+
$this->info('All done!');
34+
}
35+
}

app/Http/Controllers/Cpanel/AnalyticsController.php

-16
This file was deleted.

app/Http/Controllers/Cpanel/DashboardController.php

-25
This file was deleted.

app/Http/Controllers/Cpanel/UserController.php

-19
This file was deleted.

app/Http/Controllers/NotchPayCallBackController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Http\Request;
1212
use Illuminate\Support\Facades\Cache;
1313
use Illuminate\Support\Facades\Log;
14+
use NotchPay\Exceptions\ApiException;
1415
use NotchPay\NotchPay;
1516
use NotchPay\Payment;
1617

@@ -40,6 +41,7 @@ public function __invoke(Request $request): RedirectResponse
4041
} else {
4142
// @ToDO Envoie de mail de notification de remerciement pour le sponsoring si l'utilisateur est dans la base de données
4243
event(new SponsoringPaymentInitialize($transaction));
44+
4345
Cache::forget(key: 'sponsors');
4446

4547
session()->flash(
@@ -48,7 +50,7 @@ public function __invoke(Request $request): RedirectResponse
4850
);
4951
}
5052

51-
} catch (\NotchPay\Exceptions\ApiException $e) {
53+
} catch (ApiException $e) {
5254
Log::error($e->getMessage());
5355
session()->flash(
5456
key: 'error',

app/Http/Controllers/ReplyAbleController.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
final class ReplyAbleController extends Controller
1111
{
12-
public function redirect(int $id, string $type): RedirectResponse
12+
public function __invoke(int $id, string $type): RedirectResponse
1313
{
14-
$reply = Reply::where('replyable_id', $id)->where('replyable_type', $type)->firstOrFail();
14+
$reply = Reply::query()
15+
->where('replyable_id', $id)
16+
->where('replyable_type', $type)
17+
->firstOrFail();
1518

1619
return redirect(route_to_reply_able($reply->replyAble));
1720
}

app/Http/Controllers/SubscriptionController.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function unsubscribe(Subscribe $subscription): RedirectResponse
1414
/** @var \App\Models\Thread $thread */
1515
$thread = $subscription->subscribeAble;
1616

17-
$thread->subscribes()->where('user_id', $subscription->user->id)->delete(); // @phpstan-ignore-line
17+
$thread->subscribes()->where('user_id', $subscription->user->id)->delete();
1818

1919
session()->flash('status', __('Vous êtes maintenant désabonné de ce sujet.'));
2020

@@ -23,7 +23,10 @@ public function unsubscribe(Subscribe $subscription): RedirectResponse
2323

2424
public function redirect(int $id, string $type): RedirectResponse
2525
{
26-
$subscribe = Subscribe::where('subscribeable_id', $id)->where('subscribeable_type', $type)->firstOrFail();
26+
$subscribe = Subscribe::query()
27+
->where('subscribeable_id', $id)
28+
->where('subscribeable_type', $type)
29+
->firstOrFail();
2730

2831
return redirect(route_to_reply_able($subscribe->subscribeAble));
2932
}

app/Http/Controllers/User/ProfileController.php

-53
This file was deleted.

app/Http/Controllers/User/SettingController.php

-94
This file was deleted.

app/Http/Requests/UpdateProfileRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function rules(): array
1919
return [
2020
'name' => 'required|max:255',
2121
'email' => 'required|email|max:255|unique:users,email,'.Auth::id(),
22-
'username' => 'required|alpha_dash|max:255|unique:users,username,'.Auth::id(),
22+
'username' => 'required|alpha_dash|max:30|unique:users,username,'.Auth::id(),
2323
'twitter_profile' => 'max:255|nullable|unique:users,twitter_profile,'.Auth::id(),
2424
'github_profile' => 'max:255|nullable|unique:users,github_profile,'.Auth::id(),
2525
'bio' => 'nullable|max:160',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Livewire\Components\User;
6+
7+
use App\Models\Activity;
8+
use App\Models\User;
9+
use Illuminate\Contracts\View\View;
10+
use Livewire\Component;
11+
12+
final class Activities extends Component
13+
{
14+
public User $user;
15+
16+
public function render(): View
17+
{
18+
return view('livewire.components.user.activities', [
19+
'activities' => Activity::latestFeed($this->user),
20+
]);
21+
}
22+
}

0 commit comments

Comments
 (0)