refactor: code style changes
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
@@ -21,8 +21,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\ProfileAlreadyExistsException;
|
||||
use App\Exceptions\ProfileCreationFailedException;
|
||||
use App\Exceptions\ProfileNotFoundException;
|
||||
use App\Facades\IP;
|
||||
use App\Http\Requests\ProfileSave;
|
||||
@@ -32,13 +30,13 @@ use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
private ProfileService $profileService;
|
||||
|
||||
public function __construct(ProfileService $profileService) {
|
||||
public function __construct(ProfileService $profileService)
|
||||
{
|
||||
$this->profileService = $profileService;
|
||||
}
|
||||
|
||||
@@ -60,27 +58,22 @@ class ProfileController extends Controller
|
||||
|
||||
public function showSingleProfile(AccountSuspensionService $accountSuspensionService, User $user)
|
||||
{
|
||||
|
||||
if (is_null($user->profile)) {
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', "This user doesn't have a profile.");
|
||||
|
||||
}
|
||||
|
||||
$socialMediaProfiles = json_decode($user->profile->socialLinks, true);
|
||||
$createdDate = Carbon::parse($user->created_at);
|
||||
|
||||
|
||||
$suspensionInfo = null;
|
||||
if ($accountSuspensionService->isSuspended($user))
|
||||
{
|
||||
if ($accountSuspensionService->isSuspended($user)) {
|
||||
$suspensionInfo = [
|
||||
|
||||
'isPermanent' => $user->bans->isPermanent,
|
||||
'reason' => $user->bans->reason,
|
||||
'bannedUntil' => $user->bans->bannedUntil
|
||||
'bannedUntil' => $user->bans->bannedUntil,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -94,7 +87,7 @@ class ProfileController extends Controller
|
||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||
'since' => $createdDate->englishMonth.' '.$createdDate->year,
|
||||
'ipInfo' => IP::lookup($user->currentIp),
|
||||
'suspensionInfo' => $suspensionInfo
|
||||
'suspensionInfo' => $suspensionInfo,
|
||||
]);
|
||||
} else {
|
||||
abort(403, __('You cannot view someone else\'s profile.'));
|
||||
@@ -104,23 +97,20 @@ class ProfileController extends Controller
|
||||
public function saveProfile(ProfileSave $request)
|
||||
{
|
||||
$this->profileService->updateProfile(Auth::user()->id, $request);
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success', __('Profile updated.'));
|
||||
}
|
||||
|
||||
|
||||
public function createProfile(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$this->profileService->createProfile($request->user());
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return redirect()
|
||||
@@ -128,24 +118,18 @@ class ProfileController extends Controller
|
||||
->with('success', __('Your profile has been created.'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deleteProfile(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$this->profileService->deleteProfile($request->user());
|
||||
} catch (ProfileNotFoundException $e) {
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success', __('Profile deleted successfully.'));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user