Skip to content

Commit

Permalink
(Update) CRUDDY PT.6 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
HDVinnie committed Oct 23, 2019
1 parent 426b801 commit e001055
Show file tree
Hide file tree
Showing 28 changed files with 327 additions and 455 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Staff/BanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BanController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getBans()
public function index()
{
$bans = Ban::latest()->paginate(25);

Expand All @@ -45,7 +45,7 @@ public function getBans()
*
* @return Illuminate\Http\RedirectResponse
*/
public function ban(Request $request, $id)
public function store(Request $request, $id)
{
$user = User::findOrFail($id);
$staff = $request->user();
Expand Down Expand Up @@ -96,7 +96,7 @@ public function ban(Request $request, $id)
*
* @return Illuminate\Http\RedirectResponse
*/
public function unban(Request $request, $id)
public function update(Request $request, $id)
{
$user = User::findOrFail($id);
$staff = $request->user();
Expand Down
22 changes: 0 additions & 22 deletions app/Http/Controllers/Staff/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

namespace App\Http\Controllers\Staff;

use App\Models\Message;
use App\Models\Chatroom;
use App\Models\ChatStatus;
use Illuminate\Http\Request;
use App\Events\MessageDeleted;
use App\Http\Controllers\Controller;
use App\Repositories\ChatRepository;

Expand Down Expand Up @@ -203,24 +201,4 @@ public function deleteChatStatus($id)
return redirect()->route('chatManager')
->withSuccess('Chat Status Successfully Deleted');
}

/**
* Flush Chat Messages.
*
* @return Illuminate\Http\RedirectResponse
*/
public function flushChat()
{
foreach (Message::all() as $message) {
broadcast(new MessageDeleted($message));
$message->delete();
}

$this->chat->systemMessage(
'Chatbox Has Been Flushed! :broom:'
);

return redirect()->route('staff.dashboard.index')
->withSuccess('Chatbox Has Been Flushed');
}
}
26 changes: 24 additions & 2 deletions app/Http/Controllers/Staff/FlushController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace App\Http\Controllers\Staff;

use App\Events\MessageDeleted;
use App\Models\Message;
use Carbon\Carbon;
use App\Models\Peer;
use App\Models\History;
Expand All @@ -21,11 +23,11 @@
class FlushController extends Controller
{
/**
* Delete All Old Peers From Database.
* Flsuh All Old Peers From Database.
*
* @return Illuminate\Http\RedirectResponse
*/
public function deleteOldPeers()
public function peers()
{
$current = new Carbon();
$peers = Peer::select(['id', 'info_hash', 'user_id', 'updated_at'])->where('updated_at', '<', $current->copy()->subHours(2)->toDateTimeString())->get();
Expand All @@ -42,4 +44,24 @@ public function deleteOldPeers()
return redirect()->route('staff.dashboard.index')
->withSuccess('Ghost Peers Have Been Flushed');
}

/**
* Flush All Chat Messages.
*
* @return Illuminate\Http\RedirectResponse
*/
public function flush()
{
foreach (Message::all() as $message) {
broadcast(new MessageDeleted($message));
$message->delete();
}

$this->chat->systemMessage(
'Chatbox Has Been Flushed! :broom:'
);

return redirect()->route('staff.dashboard.index')
->withSuccess('Chatbox Has Been Flushed');
}
}
46 changes: 46 additions & 0 deletions app/Http/Controllers/Staff/MassActionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
*
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/

namespace App\Http\Controllers\Staff;

use App\Models\User;
use App\Models\Group;

class MassActionController extends Controller
{
/**
* Mass Validate Unvalidated Users.
*
* @return Illuminate\Http\RedirectResponse
*/
public function validate()
{
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
$users = User::where('active', '=', 0)->where('group_id', '=', $validatingGroup->id)->get();

foreach ($users as $user) {
$user->group_id = $memberGroup->id;
$user->active = 1;
$user->can_upload = 1;
$user->can_download = 1;
$user->can_request = 1;
$user->can_comment = 1;
$user->can_invite = 1;
$user->save();
}

return redirect()->route('staff.dashboard.index')
->withSuccess('Unvalidated Accounts Are Now Validated');
}
}
16 changes: 8 additions & 8 deletions app/Http/Controllers/Staff/ModerationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public function __construct(ChatRepository $chat)
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function moderation()
public function index()
{
$current = Carbon::now();
$pending = Torrent::with(['user', 'category'])->pending()->get();
$postponed = Torrent::with(['user', 'category'])->postponed()->get();
$rejected = Torrent::with(['user', 'category'])->rejected()->get();

return view('Staff.torrent.moderation', [
return view('Staff.moderation.index', [
'current' => $current,
'pending' => $pending,
'postponed' => $postponed,
Expand Down Expand Up @@ -90,10 +90,10 @@ public function approve($id)

TorrentHelper::approveHelper($torrent->id);

return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withSuccess('Torrent Approved');
} else {
return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withErrors('Torrent Already Approved');
}
}
Expand All @@ -114,7 +114,7 @@ public function postpone(Request $request)
]);

if ($v->fails()) {
return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withErrors($v->errors());
} else {
$user = $request->user();
Expand All @@ -128,7 +128,7 @@ public function postpone(Request $request)
$pm->message = "Greetings, \n\n Your upload, {$torrent->name} ,has been postponed. Please see below the message from the staff member. \n\n{$request->input('message')}";
$pm->save();

return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withSuccess('Torrent Postponed');
}
}
Expand All @@ -149,7 +149,7 @@ public function reject(Request $request)
]);

if ($v->fails()) {
return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withErrors($v->errors());
} else {
$user = $request->user();
Expand All @@ -163,7 +163,7 @@ public function reject(Request $request)
$pm->message = "Greetings, \n\n Your upload {$torrent->name} has been rejected. Please see below the message from the staff member. \n\n{$request->input('message')}";
$pm->save();

return redirect()->route('moderation')
return redirect()->route('staff.moderation.index')
->withSuccess('Torrent Rejected');
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/Staff/NoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
class NoteController extends Controller
{
/**
* Get All User Notes.
* Display All User Notes.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getNotes()
public function index()
{
$notes = Note::latest()->paginate(25);

return view('Staff.note.index', ['notes' => $notes]);
}

/**
* Post A User Note.
* Store A New User Note.
*
* @param \Illuminate\Http\Request $request
* @param $id
*
* @return Illuminate\Http\RedirectResponse
*/
public function postNote(Request $request, $id)
public function store(Request $request, $id)
{
$staff = $request->user();
$user = User::findOrFail($id);
Expand Down Expand Up @@ -77,7 +77,7 @@ public function postNote(Request $request, $id)
*
* @return Illuminate\Http\RedirectResponse
*/
public function deleteNote($id)
public function destroy($id)
{
$note = Note::findOrFail($id);
$user = User::findOrFail($note->user_id);
Expand Down
13 changes: 7 additions & 6 deletions app/Http/Controllers/Staff/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,29 @@ public function __construct(ChatRepository $chat)
}

/**
* Show All Polls.
* Display All Polls.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function polls()
public function index()
{
$polls = Poll::latest()->paginate(25);

return view('Staff.poll.polls', ['polls' => $polls]);
return view('Staff.poll.index', ['polls' => $polls]);
}

/**
* Show A Poll.
*
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function poll($id)
public function show($id)
{
$poll = Poll::where('id', '=', $id)->firstOrFail();

return view('Staff.poll.poll', ['poll' => $poll]);
return view('Staff.poll.show', ['poll' => $poll]);
}

/**
Expand Down Expand Up @@ -102,7 +103,7 @@ public function store(StorePoll $request)
"A new poll has been created [url={$poll_url}]{$poll->title}[/url] vote on it now! :slight_smile:"
);

return redirect('poll/'.$poll->slug)
return redirect()->route('staff.polls.index')
->withSuccess('Your poll has been created.');
}
}
26 changes: 13 additions & 13 deletions app/Http/Controllers/Staff/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@
class ReportController extends Controller
{
/**
* Get All Reports.
* Display All Reports.
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getReports()
public function index()
{
$reports = Report::latest()->paginate(25);

return view('Staff.report.index', ['reports' => $reports]);
}

/**
* Get A Report.
* Show A Report.
*
* @param $report_id
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getReport($report_id)
public function show($id)
{
$report = Report::findOrFail($report_id);
$report = Report::findOrFail($id);

preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $report->message, $match);

return view('Staff.report.report', ['report' => $report, 'urls' => $match[0]]);
return view('Staff.report.show', ['report' => $report, 'urls' => $match[0]]);
}

/**
* Solve A Report.
* Update A Report.
*
* @param Request $request
* @param $report_id
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function solveReport(Request $request, $report_id)
public function update(Request $request, $id)
{
$user = auth()->user();

Expand All @@ -65,10 +65,10 @@ public function solveReport(Request $request, $report_id)
'staff_id' => 'required',
]);

$report = Report::findOrFail($report_id);
$report = Report::findOrFail($id);

if ($report->solved == 1) {
return redirect()->route('getReports')
return redirect()->route('staff.reports.index')
->withErrors('This Report Has Already Been Solved');
}

Expand All @@ -89,7 +89,7 @@ public function solveReport(Request $request, $report_id)
[b]VERDICT:[/b] {$report->verdict}";
$pm->save();

return redirect()->route('getReports')
return redirect()->route('staff.reports.index')
->withSuccess('Report has been successfully resolved');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Staff/SeedboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function index()
{
$seedboxes = Seedbox::with('user')->latest()->paginate(50);

return view('Staff.seedboxe.index', ['seedboxes' => $seedboxes]);
return view('Staff.seedbox.index', ['seedboxes' => $seedboxes]);
}

/**
Expand Down
Loading

0 comments on commit e001055

Please sign in to comment.