Update AdminUserController, add moderation method

This commit is contained in:
Daniel Supernault 2020-02-19 20:45:11 -07:00
parent a73fad75b0
commit a4cf21eaad
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 34 additions and 0 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
use Cache, DB;
use Illuminate\Http\Request;
use App\ModLog;
use App\Profile;
use App\User;
use App\Mail\AdminMessage;
use Illuminate\Support\Facades\Mail;
@ -155,4 +156,37 @@ trait AdminUserController
$profile = $user->profile;
return view('admin.users.delete', compact('user', 'profile'));
}
public function userModerate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|exists:profiles,id',
'action' => 'required|in:cw,no_autolink,unlisted'
]);
$pid = $request->input('profile_id');
$action = $request->input('action');
$profile = Profile::findOrFail($pid);
switch ($action) {
case 'cw':
$profile->cw = true;
$msg = "Successfully added Content Warnings to {$profile->username}'s future posts!";
break;
case 'no_autolink':
$profile->no_autolink = true;
$msg = "Successfully applied No Autolinking to {$profile->username}'s future posts!";
break;
case 'unlisted':
$profile->unlisted = true;
$msg = "Successfully applied Unlisted scope to {$profile->username}'s future posts!";
break;
}
$profile->save();
$request->session()->flash('status', $msg);
return redirect('/i/admin/users/show/' . $profile->user_id);
}
}