Apply fixes from StyleCI
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Miguel Nogueira
|
||||
*
|
||||
* This file is part of Raspberry Staff Manager.
|
||||
*
|
||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileSave;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Profile;
|
||||
use App\User;
|
||||
use App\Facades\IP;
|
||||
use App\Http\Requests\ProfileSave;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -14,18 +31,15 @@ use Spatie\Permission\Models\Role;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
return view('dashboard.user.directory')
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.user.directory')
|
||||
->with('users', User::with('profile', 'bans')->paginate(9));
|
||||
}
|
||||
}
|
||||
|
||||
public function showProfile()
|
||||
{
|
||||
|
||||
$socialLinks = Auth::user()->profile->socialLinks ?? "[]";
|
||||
$socialLinks = Auth::user()->profile->socialLinks ?? '[]';
|
||||
$socialMediaProfiles = json_decode($socialLinks, true);
|
||||
|
||||
return view('dashboard.user.profile.userprofile')
|
||||
@@ -36,13 +50,11 @@ class ProfileController extends Controller
|
||||
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
// Route model binding
|
||||
public function showSingleProfile(Request $request, User $user)
|
||||
{
|
||||
|
||||
$socialMediaProfiles = json_decode($user->profile->socialLinks, true);
|
||||
$createdDate = Carbon::parse($user->created_at);
|
||||
|
||||
@@ -51,21 +63,15 @@ class ProfileController extends Controller
|
||||
|
||||
$roleList = [];
|
||||
|
||||
|
||||
foreach($systemRoles as $role)
|
||||
{
|
||||
if (in_array($role, $userRoles))
|
||||
{
|
||||
$roleList[$role] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$roleList[$role] = false;
|
||||
}
|
||||
foreach ($systemRoles as $role) {
|
||||
if (in_array($role, $userRoles)) {
|
||||
$roleList[$role] = true;
|
||||
} else {
|
||||
$roleList[$role] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others'))
|
||||
{
|
||||
if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others')) {
|
||||
return view('dashboard.user.profile.displayprofile')
|
||||
->with([
|
||||
'profile' => $user->profile,
|
||||
@@ -73,16 +79,13 @@ class ProfileController extends Controller
|
||||
'twitter' => $socialMediaProfiles['links']['twitter'] ?? 'UpdateMe',
|
||||
'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe',
|
||||
'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345',
|
||||
'since' => $createdDate->englishMonth . " " . $createdDate->year,
|
||||
'since' => $createdDate->englishMonth.' '.$createdDate->year,
|
||||
'ipInfo' => IP::lookup($user->originalIP),
|
||||
'roles' => $roleList
|
||||
'roles' => $roleList,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
abort(403, 'You cannot view someone else\'s profile.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function saveProfile(ProfileSave $request)
|
||||
@@ -90,10 +93,8 @@ class ProfileController extends Controller
|
||||
$profile = User::find(Auth::user()->id)->profile;
|
||||
$social = [];
|
||||
|
||||
if (!is_null($profile))
|
||||
{
|
||||
switch ($request->avatarPref)
|
||||
{
|
||||
if (! is_null($profile)) {
|
||||
switch ($request->avatarPref) {
|
||||
case 'MOJANG':
|
||||
$avatarPref = 'crafatar';
|
||||
|
||||
@@ -117,11 +118,8 @@ class ProfileController extends Controller
|
||||
$newProfile = $profile->save();
|
||||
|
||||
$request->session()->flash('success', 'Profile settings saved successfully.');
|
||||
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user