mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-22 10:08:31 -05:00
(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:
@@ -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']));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user