Apply fixes from StyleCI
This commit is contained in:
parent
75de27f482
commit
b8abbdd90f
261 changed files with 3368 additions and 3231 deletions
|
@ -2,9 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Profile;
|
||||
use App\Report;
|
||||
use App\Status;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\{Avatar, Profile, Report, Status, User};
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
|
@ -12,95 +15,96 @@ class ReportController extends Controller
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function showForm(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
$this->validate($request, [
|
||||
'type' => 'required|alpha_dash',
|
||||
'id' => 'required|integer|min:1'
|
||||
'id' => 'required|integer|min:1',
|
||||
]);
|
||||
return view('report.form');
|
||||
|
||||
return view('report.form');
|
||||
}
|
||||
|
||||
public function notInterestedForm(Request $request)
|
||||
{
|
||||
return view('report.not-interested');
|
||||
return view('report.not-interested');
|
||||
}
|
||||
|
||||
public function spamForm(Request $request)
|
||||
{
|
||||
return view('report.spam');
|
||||
return view('report.spam');
|
||||
}
|
||||
|
||||
public function spamCommentForm(Request $request)
|
||||
{
|
||||
return view('report.spam.comment');
|
||||
return view('report.spam.comment');
|
||||
}
|
||||
|
||||
public function spamPostForm(Request $request)
|
||||
{
|
||||
return view('report.spam.post');
|
||||
return view('report.spam.post');
|
||||
}
|
||||
|
||||
public function spamProfileForm(Request $request)
|
||||
{
|
||||
return view('report.spam.profile');
|
||||
return view('report.spam.profile');
|
||||
}
|
||||
|
||||
public function sensitiveCommentForm(Request $request)
|
||||
{
|
||||
return view('report.sensitive.comment');
|
||||
return view('report.sensitive.comment');
|
||||
}
|
||||
|
||||
public function sensitivePostForm(Request $request)
|
||||
{
|
||||
return view('report.sensitive.post');
|
||||
return view('report.sensitive.post');
|
||||
}
|
||||
|
||||
public function sensitiveProfileForm(Request $request)
|
||||
{
|
||||
return view('report.sensitive.profile');
|
||||
return view('report.sensitive.profile');
|
||||
}
|
||||
|
||||
public function abusiveCommentForm(Request $request)
|
||||
{
|
||||
return view('report.abusive.comment');
|
||||
return view('report.abusive.comment');
|
||||
}
|
||||
|
||||
public function abusivePostForm(Request $request)
|
||||
{
|
||||
return view('report.abusive.post');
|
||||
return view('report.abusive.post');
|
||||
}
|
||||
|
||||
public function abusiveProfileForm(Request $request)
|
||||
{
|
||||
return view('report.abusive.profile');
|
||||
return view('report.abusive.profile');
|
||||
}
|
||||
|
||||
|
||||
public function formStore(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
$this->validate($request, [
|
||||
'report' => 'required|alpha_dash',
|
||||
'type' => 'required|alpha_dash',
|
||||
'id' => 'required|integer|min:1',
|
||||
'msg' => 'nullable|string|max:150'
|
||||
'msg' => 'nullable|string|max:150',
|
||||
]);
|
||||
|
||||
$profile = Auth::user()->profile;
|
||||
$reportType = $request->input('report');
|
||||
$object_id = $request->input('id');
|
||||
$object_type = $request->input('type');
|
||||
$msg = $request->input('msg');
|
||||
$object = null;
|
||||
$types = ['spam', 'sensitive', 'abusive'];
|
||||
$profile = Auth::user()->profile;
|
||||
$reportType = $request->input('report');
|
||||
$object_id = $request->input('id');
|
||||
$object_type = $request->input('type');
|
||||
$msg = $request->input('msg');
|
||||
$object = null;
|
||||
$types = ['spam', 'sensitive', 'abusive'];
|
||||
|
||||
if(!in_array($reportType, $types)) {
|
||||
return redirect('/timeline')->with('error', 'Invalid report type');
|
||||
}
|
||||
if (!in_array($reportType, $types)) {
|
||||
return redirect('/timeline')->with('error', 'Invalid report type');
|
||||
}
|
||||
|
||||
switch ($object_type) {
|
||||
switch ($object_type) {
|
||||
case 'post':
|
||||
$object = Status::findOrFail($object_id);
|
||||
$object_type = 'App\Status';
|
||||
|
@ -109,31 +113,30 @@ class ReportController extends Controller
|
|||
->whereObjectType('App\Status')
|
||||
->count();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return redirect('/timeline')->with('error', 'Invalid report type');
|
||||
break;
|
||||
}
|
||||
|
||||
if($exists !== 0) {
|
||||
return redirect('/timeline')->with('error', 'You have already reported this!');
|
||||
}
|
||||
if ($exists !== 0) {
|
||||
return redirect('/timeline')->with('error', 'You have already reported this!');
|
||||
}
|
||||
|
||||
if($object->profile_id == $profile->id) {
|
||||
return redirect('/timeline')->with('error', 'You cannot report your own content!');
|
||||
}
|
||||
if ($object->profile_id == $profile->id) {
|
||||
return redirect('/timeline')->with('error', 'You cannot report your own content!');
|
||||
}
|
||||
|
||||
$report = new Report;
|
||||
$report->profile_id = $profile->id;
|
||||
$report->user_id = Auth::id();
|
||||
$report->object_id = $object->id;
|
||||
$report->object_type = $object_type;
|
||||
$report->reported_profile_id = $object->profile_id;
|
||||
$report->type = $request->input('report');
|
||||
$report->message = $request->input('msg');
|
||||
$report->save();
|
||||
$report = new Report();
|
||||
$report->profile_id = $profile->id;
|
||||
$report->user_id = Auth::id();
|
||||
$report->object_id = $object->id;
|
||||
$report->object_type = $object_type;
|
||||
$report->reported_profile_id = $object->profile_id;
|
||||
$report->type = $request->input('report');
|
||||
$report->message = $request->input('msg');
|
||||
$report->save();
|
||||
|
||||
return redirect('/timeline')->with('status', 'Report successfully sent!');
|
||||
return redirect('/timeline')->with('status', 'Report successfully sent!');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue