From c077f6625d1a177ac34fa583d147ce5aa1f45ab3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 9 Aug 2018 21:17:24 -0600 Subject: [PATCH] Update SettingsController --- app/Http/Controllers/SettingsController.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 48ca6150a..f3a8415cb 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -3,19 +3,28 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; -use App\{AccountLog, Profile, User}; +use App\{AccountLog, Media, Profile, User}; use Auth, DB; +use App\Util\Lexer\PrettyNumber; class SettingsController extends Controller { public function __construct() { - return $this->middleware('auth'); + $this->middleware('auth'); } public function home() { - return view('settings.home'); + $id = Auth::user()->profile->id; + $storage = []; + $used = Media::whereProfileId($id)->sum('size'); + $storage['limit'] = config('pixelfed.max_account_size') * 1024; + $storage['used'] = $used; + $storage['percentUsed'] = ceil($storage['used'] / $storage['limit'] * 100); + $storage['limitPretty'] = PrettyNumber::size($storage['limit']); + $storage['usedPretty'] = PrettyNumber::size($storage['used']); + return view('settings.home', compact('storage')); } public function homeUpdate(Request $request)