Update SettingsController

This commit is contained in:
Daniel Supernault 2018-08-30 22:29:38 -06:00
parent 0508900b46
commit d8d73298a9
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -7,6 +7,7 @@ use App\EmailVerification;
use App\Media;
use App\Profile;
use App\User;
use App\UserFilter;
use App\Util\Lexer\PrettyNumber;
use Auth;
use DB;
@ -254,4 +255,64 @@ class SettingsController extends Controller
{
return view('settings.developers');
}
public function mutedUsers()
{
$pid = Auth::user()->profile->id;
$ids = (new UserFilter())->mutedUserIds($pid);
$users = Profile::whereIn('id', $ids)->simplePaginate(15);
return view('settings.privacy.muted', compact('users'));
}
public function mutedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1'
]);
$fid = $request->input('profile_id');
$pid = Auth::user()->profile->id;
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterType('mute')
->firstOrFail();
$filter->delete();
});
return redirect()->back();
}
public function blockedUsers()
{
$pid = Auth::user()->profile->id;
$ids = (new UserFilter())->blockedUserIds($pid);
$users = Profile::whereIn('id', $ids)->simplePaginate(15);
return view('settings.privacy.blocked', compact('users'));
}
public function blockedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1'
]);
$fid = $request->input('profile_id');
$pid = Auth::user()->profile->id;
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterType('block')
->firstOrFail();
$filter->delete();
});
return redirect()->back();
}
public function blockedInstances()
{
$settings = Auth::user()->settings;
return view('settings.privacy.blocked-instances');
}
}