(Refactored) Report System ref #209

Visually more appealing.
Will now reference urls in the message body.
Includes reported user AND reported by user.
Title now links to the torrent reported.
This commit is contained in:
poppabear8883
2018-04-22 17:15:24 -04:00
parent 11e0300a1a
commit 9240bc2c35
10 changed files with 941 additions and 723 deletions
+28 -19
View File
@@ -13,38 +13,47 @@
namespace App\Http\Controllers;
use App\Report;
use App\Torrent;
use Illuminate\Http\Request;
use \Toastr;
class ReportController extends Controller
{
/**
* Reports System
*
*
* @var Report
*/
private $report;
/**
* @var Torrent
*/
private $torrent;
public function __construct(Report $report, Torrent $torrent)
{
$this->report = $report;
$this->torrent = $torrent;
}
public function postReport(Request $request)
{
$user = auth()->user();
$torrent = $this->torrent->find($request->get('torrent_id'));
$reported_by = auth()->user();
$reported_user = $torrent->user;
$v = validator($request->all(), [
'type' => 'required',
'reporter_id' => 'required|numeric',
'title' => 'required',
'message' => 'required',
'solved' => 'required|numeric'
$this->report->create([
'type' => $request->get('type'),
'torrent_id' => $torrent->id,
'reporter_id' => $reported_by->id,
'reported_user' => $reported_user->id,
'title' => $torrent->name,
'message' => $request->get('message'),
'solved' => 0
]);
$report = new Report();
$report->type = $request->input('type');
$report->reporter_id = $user->id;
$report->title = $request->input('title');
$report->message = $request->input('message');
$report->solved = 0;
$report->save();
// Activity Log
\LogActivity::addToLog("Member {$user->username} has made a new {$report->type} report.");
\LogActivity::addToLog("Member {$reported_by->username} has made a new {$request->get('type')} report.");
return redirect()->route('home')->with(Toastr::success('Your report has been successfully sent', 'Yay!', ['options']));
}