(Update) Controller + Commands Query Syntax

- using shorter and more readable syntax
- remove “=“ in where clauses
- uses oldest() / latest() instead of like orderBy('created_at', 'DESC')
This commit is contained in:
HDVinnie
2018-03-24 16:42:59 -04:00
parent e3e21896e2
commit 32e8b1c62b
38 changed files with 219 additions and 219 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ class FlushPeers extends Command
Peer::chunk(250, function ($section) {
foreach ($section as $data) {
if ((time() - strtotime($data->updated_at)) > (60 * 60 * 2)) {
History::where("info_hash", "=", $data->hash)->where("user_id", "=", $data->user_id)->update(['active' => false]);
History::where("info_hash", $data->hash)->where("user_id", $data->user_id)->update(['active' => false]);
$data->delete();
}
}
+1 -1
View File
@@ -43,7 +43,7 @@ class autoBan extends Command
*/
public function handle()
{
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', config('hitrun.buffer'))->get();
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.buffer'))->get();
foreach ($bans as $ban) {
if ($ban->warneduser->group_id != 5 && !$ban->warneduser->group->is_immune) {
+3 -3
View File
@@ -46,9 +46,9 @@ class autoGraveyard extends Command
$rewardable = Graveyard::where('rewarded', '!=', 1)->get();
foreach ($rewardable as $reward) {
$user = User::where('id', '=', $reward->user_id)->first();
$torrent = Torrent::where('id', '=', $reward->torrent_id)->first();
$history = History::where('info_hash', '=', $torrent->info_hash)->where('user_id', '=', $user->id)->first();
$user = User::where('id', $reward->user_id)->first();
$torrent = Torrent::where('id', $reward->torrent_id)->first();
$history = History::where('info_hash', $torrent->info_hash)->where('user_id', $user->id)->first();
if ($history && $history->seedtime >= $reward->seedtime) {
$reward->rewarded = 1;
+2 -2
View File
@@ -44,11 +44,11 @@ class autoGroup extends Command
{
// Temp Hard Coding of Immune Groups (Config Files To Come)
$current = Carbon::now();
$groups = Group::select('id')->where('autogroup', '=', 1)->get()->toArray();
$groups = Group::select('id')->where('autogroup', 1)->get()->toArray();
$users = User::whereIn('group_id', $groups)->get();
foreach ($users as $user) {
$hiscount = History::where('user_id', '=', $user->id)->count();
$hiscount = History::where('user_id', $user->id)->count();
// Temp Hard Coding of Group Requirements (Config Files To Come) (Upload in Bytes!) (Seedtime in Seconds!)
+6 -6
View File
@@ -52,17 +52,17 @@ class autoNerdStat extends Command
// New Users Count Last 24hours
$users = User::where('created_at', '>', $current->subDay())->count();
// Top Banker
$banker = User::orderBy('seedbonus', 'DESC')->first();
$banker = User::latest('seedbonus')->first();
// Most Snatched Torrent
$snatched = Torrent::orderBy('times_completed', 'DESC')->first();
$snatched = Torrent::latest('times_completed')->first();
// Most Seeded Torrent
$seeders = Torrent::orderBy('seeders', 'DESC')->first();
$seeders = Torrent::latest('seeders')->first();
// Most Leeched Torrent
$leechers = Torrent::orderBy('leechers', 'DESC')->first();
$leechers = Torrent::latest('leechers')->first();
// FL Torrents
$fl = Torrent::where('free', '=', 1)->count();
$fl = Torrent::where('free', 1)->count();
// DU Torrents
$du = Torrent::where('doubleup', '=', 1)->count();
$du = Torrent::where('doubleup', 1)->count();
// Select A Random Nerd Stat
$statArray = ["In The Last 24 Hours " . $logins . " Unique Users Have Logged Into " . config('other.title') . "!",
+2 -2
View File
@@ -46,7 +46,7 @@ class autoPreWarning extends Command
$current = new Carbon();
$prewarn = History::with(['user', 'torrent'])
->where('actual_downloaded', '>', 0)
->where('active', '=', 0)
->where('active', 0)
->where('seedtime', '<=', config('hitrun.seedtime'))
->where('updated_at', '<', $current->copy()->subDays(config('hitrun.prewarn'))->toDateTimeString())
->get();
@@ -54,7 +54,7 @@ class autoPreWarning extends Command
foreach ($prewarn as $pre) {
if (!$pre->user->group->is_immune) {
if ($pre->actual_downloaded > ($pre->torrent->size * (config('hitrun.buffer') / 100))) {
$exsist = Warning::where('torrent', '=', $pre->torrent->id)->where('user_id', '=', $pre->user->id)->first();
$exsist = Warning::where('torrent', $pre->torrent->id)->where('user_id', $pre->user->id)->first();
// Send Pre Warning PM If Actual Warning Doesnt Already Exsist
if (!$exsist) {
+1 -1
View File
@@ -49,7 +49,7 @@ class autoSeedbox extends Command
$torid = Peer::select('torrent_id')->whereIn('ip', $seedboxips)->where('seeder', 1)->get()->toArray();
foreach ($torid as $id) {
$torrent = Torrent::where('id', '=', $id)->first();
$torrent = Torrent::where('id', $id)->first();
$torrent->highspeed = 1;
$torrent->save();
+2 -2
View File
@@ -45,7 +45,7 @@ class autoWarning extends Command
$current = new Carbon();
$hitrun = History::with(['user', 'torrent'])
->where('actual_downloaded', '>', 0)
->where('active', '=', 0)
->where('active', 0)
->where('seedtime', '<=', config('hitrun.seedtime'))
->where('updated_at', '<', $current->copy()->subDays(config('hitrun.grace'))->toDateTimeString())
->get();
@@ -53,7 +53,7 @@ class autoWarning extends Command
foreach ($hitrun as $hr) {
if (!$hr->user->group->is_immune) {
if ($hr->actual_downloaded > ($hr->torrent->size * (config('hitrun.buffer') / 100))) {
$exsist = Warning::where('torrent', '=', $hr->torrent->id)->where('user_id', '=', $hr->user->id)->first();
$exsist = Warning::where('torrent', $hr->torrent->id)->where('user_id', $hr->user->id)->first();
// Insert Warning Into Warnings Table if doesnt already exsist
if (!$exsist) {
+13 -13
View File
@@ -45,9 +45,9 @@ class bonAllocation extends Command
$dying = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('torrents.seeders', '=', 1)
->where('torrents.seeders', 1)
->where('torrents.times_completed', '>', 2)
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
->groupBy('peers.user_id')
->get()
@@ -56,7 +56,7 @@ class bonAllocation extends Command
$legendary = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->whereRaw('torrents.created_at < date_sub(now(), interval 12 month)')
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
->groupBy('peers.user_id')
@@ -66,7 +66,7 @@ class bonAllocation extends Command
$old = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->whereRaw('torrents.created_at < date_sub(now(), Interval 6 month)')
->whereRaw('torrents.created_at > date_sub(now(), interval 12 month)')
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
@@ -77,7 +77,7 @@ class bonAllocation extends Command
$huge = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824 * 100)
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
->groupBy('peers.user_id')
@@ -87,7 +87,7 @@ class bonAllocation extends Command
$large = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824 * 25)
->where('torrents.size', '<', 1073741824 * 100)
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
@@ -98,7 +98,7 @@ class bonAllocation extends Command
$regular = DB::table('peers')
->select(DB::raw('count(DISTINCT(peers.hash)) as value'), 'peers.user_id')
->join('torrents', 'torrents.id', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824)
->where('torrents.size', '<', 1073741824 * 25)
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
@@ -109,7 +109,7 @@ class bonAllocation extends Command
$participaint = DB::table('history')
->select(DB::raw('count(DISTINCT(history.info_hash)) as value'), 'history.user_id')
->join('torrents', 'torrents.info_hash', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000)
->where('history.seedtime', '<', 2592000 * 2)
->groupBy('history.user_id')
@@ -120,7 +120,7 @@ class bonAllocation extends Command
$teamplayer = DB::table('history')
->select(DB::raw('count(DISTINCT(history.info_hash)) as value'), 'history.user_id')
->join('torrents', 'torrents.info_hash', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 2)
->where('history.seedtime', '<', 2592000 * 3)
->groupBy('history.user_id')
@@ -130,7 +130,7 @@ class bonAllocation extends Command
$commited = DB::table('history')
->select(DB::raw('count(DISTINCT(history.info_hash)) as value'), 'history.user_id')
->join('torrents', 'torrents.info_hash', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 3)
->where('history.seedtime', '<', 2592000 * 6)
->groupBy('history.user_id')
@@ -140,7 +140,7 @@ class bonAllocation extends Command
$mvp = DB::table('history')
->select(DB::raw('count(DISTINCT(history.info_hash)) as value'), 'history.user_id')
->join('torrents', 'torrents.info_hash', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 6)
->where('history.seedtime', '<', 2592000 * 12)
->groupBy('history.user_id')
@@ -150,7 +150,7 @@ class bonAllocation extends Command
$legendary = DB::table('history')
->select(DB::raw('count(DISTINCT(history.info_hash)) as value'), 'history.user_id')
->join('torrents', 'torrents.info_hash', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 12)
->groupBy('history.user_id')
->get()
@@ -261,7 +261,7 @@ class bonAllocation extends Command
//Move data from array to Users table
foreach ($array as $key => $value) {
$user = User::where('id', '=', $key)->first();
$user = User::where('id', $key)->first();
$user->seedbonus += $value;
$user->save();
}
+1 -1
View File
@@ -41,7 +41,7 @@ class deactivateWarning extends Command
public function handle()
{
$current = Carbon::now();
$warnings = Warning::with(['warneduser', 'torrenttitle'])->where('active', '=', '1')->where('expires_on', '<', $current)->get();
$warnings = Warning::with(['warneduser', 'torrenttitle'])->where('active', 1)->where('expires_on', '<', $current)->get();
foreach ($warnings as $warning) {
// Set Records Active To 0 in warnings table
@@ -46,7 +46,7 @@ class removeFeaturedTorrent extends Command
foreach ($featured_torrents as $featured_torrent) {
// Find The Torrent
$torrent = Torrent::where('featured', '=', 1)->where('id', '=', $featured_torrent->torrent_id)->first();
$torrent = Torrent::where('featured', 1)->where('id', $featured_torrent->torrent_id)->first();
$torrent->free = 0;
$torrent->doubleup = 0;
$torrent->featured = 0;
+4 -4
View File
@@ -42,11 +42,11 @@ class revokePermissions extends Command
public function handle()
{
User::where('group_id', '!=', '5')->where('group_id', '!=', '1')->where('group_id', '!=', '15')->update(['can_download' => '1', 'can_request' => '1']);
User::where('group_id', '=', '1')->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', '=', '5')->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', '=', '15')->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', 1)->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', 5)->update(['can_download' => '0', 'can_request' => '0']);
User::where('group_id', 15)->update(['can_download' => '0', 'can_request' => '0']);
$warning = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', '1')->groupBy('user_id')->having('value', '>=', config('hitrun.revoke'))->get();
$warning = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.revoke'))->get();
foreach ($warning as $deny) {
if ($deny->warneduser->can_download == 1 && $deny->warneduser->can_request == 1) {
+8 -8
View File
@@ -84,7 +84,7 @@ class AnnounceController extends Controller
}
// Check Passkey Against Users Table
$user = User::where("passkey", '=', $passkey)->first();
$user = User::where("passkey", $passkey)->first();
// If Passkey Doesnt Exsist Return Error to Client
if (!$user) {
@@ -160,7 +160,7 @@ class AnnounceController extends Controller
return response(Bencode::bencode(['failure reason' => "Invalid peerid: peerid is not 20 bytes long."]), 200, ['Content-Type' => 'text/plain']); }*/
// Check Info Hash Agaist Torrents Table
$torrent = Torrent::where('info_hash', '=', $hash)->first();
$torrent = Torrent::where('info_hash', $hash)->first();
// If Torrent Doesnt Exsist Return Error to Client
if (!$torrent || $torrent->id < 0) {
@@ -180,7 +180,7 @@ class AnnounceController extends Controller
return response(Bencode::bencode(['failure reason' => 'Torrent has been rejected']), 200, ['Content-Type' => 'text/plain']);
}
$peers = Peer::where('hash', '=', $hash)->take(100)->get()->toArray();
$peers = Peer::where('hash', $hash)->take(100)->get()->toArray();
$seeders = 0;
$leechers = 0;
@@ -208,7 +208,7 @@ class AnnounceController extends Controller
}
// Pull Count On Users Peers Per Torrent
$limit = Peer::where('hash', '=', $hash)->where('user_id', '=', $user->id)->count();
$limit = Peer::where('hash', $hash)->where('user_id', $user->id)->count();
// If Users Peer Count On A Single Torrent Is Greater Than 3 Return Error to Client
if ($limit > 3) {
@@ -217,7 +217,7 @@ class AnnounceController extends Controller
}
// Get The Current Peer
$client = Peer::where('hash', '=', $hash)->where('md5_peer_id', '=', $md5_peer_id)->where('user_id', '=', $user->id)->first();
$client = Peer::where('hash', $hash)->where('md5_peer_id', $md5_peer_id)->where('user_id', $user->id)->first();
// Flag is tripped if new session is created but client reports up/down > 0
$ghost = false;
@@ -234,7 +234,7 @@ class AnnounceController extends Controller
}
// Get history information
$history = History::where("info_hash", "=", $hash)->where("user_id", "=", $user->id)->first();
$history = History::where("info_hash", $hash)->where("user_id", $user->id)->first();
if (!$history) {
$history = new History([
@@ -254,8 +254,8 @@ class AnnounceController extends Controller
$old_update = $client->updated_at ? $client->updated_at->timestamp : Carbon::now()->timestamp;
// Modification of upload and Download
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
$freeleech_token = FreeleechToken::where('user_id', '=', $user->id)->where('torrent_id', '=', $torrent->id)->first();
$personal_freeleech = PersonalFreeleech::where('user_id', $user->id)->first();
$freeleech_token = FreeleechToken::where('user_id', $user->id)->where('torrent_id', $torrent->id)->first();
if (config('other.freeleech') == true || $torrent->free == 1 || $personal_freeleech || $user->group->is_freeleech == 1 || $freeleech_token) {
$mod_downloaded = 0;
+28 -28
View File
@@ -37,9 +37,9 @@ class BonusController extends Controller
public function bonus()
{
$user = auth()->user();
$users = User::orderBy('username', 'ASC')->get();
$users = User::oldest('username')->get();
$userbon = $user->getSeedbonus();
$activefl = PersonalFreeleech::where('user_id', '=', $user->id)->first();
$activefl = PersonalFreeleech::where('user_id', $user->id)->first();
$BonExchange = new BonExchange();
@@ -132,10 +132,10 @@ class BonusController extends Controller
*/
public function doItemExchange($userID, $itemID)
{
$item = BonExchange::where('id', '=', $itemID)->get()->toArray()[0];
$item = BonExchange::where('id', $itemID)->get()->toArray()[0];
$user_acc = User::findOrFail($userID);
$activefl = PersonalFreeleech::where('user_id', '=', $user_acc->id)->first();
$activefl = PersonalFreeleech::where('user_id', $user_acc->id)->first();
$bon_transactions = new BonTransactions();
if ($item['upload'] == true) {
@@ -245,7 +245,7 @@ class BonusController extends Controller
{
$user = auth()->user();
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$uploader = User::where('id', '=', $torrent->user_id)->first();
$uploader = User::where('id', $torrent->user_id)->first();
$tip_amount = $request->input('tip');
if ($tip_amount > $user->seedbonus) {
@@ -296,10 +296,10 @@ class BonusController extends Controller
return DB::table('peers')
->select('peers.hash')->distinct()
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('torrents.seeders', '=', 1)
->where('peers.seeder', 1)
->where('torrents.seeders', 1)
->where('torrents.times_completed', '>', 2)
->where('peers.user_id', '=', $user->id)
->where('peers.user_id', $user->id)
->count();
}
@@ -319,8 +319,8 @@ class BonusController extends Controller
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->whereRaw('torrents.created_at < date_sub(now(), interval 12 month)')
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
->where('peers.seeder', '=', 1)
->where('peers.user_id', '=', $user->id)
->where('peers.seeder', 1)
->where('peers.user_id', $user->id)
->count();
}
@@ -341,8 +341,8 @@ class BonusController extends Controller
->whereRaw('torrents.created_at < date_sub(now(), Interval 6 month)')
->whereRaw('torrents.created_at > date_sub(now(), interval 12 month)')
->whereRaw('date_sub(peers.created_at,interval 30 minute) < now()')
->where('peers.seeder', '=', 1)
->where('peers.user_id', '=', $user->id)
->where('peers.seeder', 1)
->where('peers.user_id', $user->id)
->count();
}
@@ -360,9 +360,9 @@ class BonusController extends Controller
return DB::table('peers')
->select('peers.hash')->distinct()
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824 * 100)
->where('peers.user_id', '=', $user->id)
->where('peers.user_id', $user->id)
->count();
}
@@ -380,10 +380,10 @@ class BonusController extends Controller
return DB::table('peers')
->select('peers.hash')->distinct()
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824 * 25)
->where('torrents.size', '<', 1073741824 * 100)
->where('peers.user_id', '=', $user->id)
->where('peers.user_id', $user->id)
->count();
}
@@ -401,10 +401,10 @@ class BonusController extends Controller
return DB::table('peers')
->select('peers.hash')->distinct()
->join('torrents', 'torrents.id', '=', 'peers.torrent_id')
->where('peers.seeder', '=', 1)
->where('peers.seeder', 1)
->where('torrents.size', '>=', 1073741824)
->where('torrents.size', '<', 1073741824 * 25)
->where('peers.user_id', '=', $user->id)
->where('peers.user_id', $user->id)
->count();
}
@@ -422,10 +422,10 @@ class BonusController extends Controller
return DB::table('history')
->select('history.seedtime')->distinct()
->join('torrents', 'torrents.info_hash', '=', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000)
->where('history.seedtime', '<', 2592000 * 2)
->where('history.user_id', '=', $user->id)
->where('history.user_id', $user->id)
->count();
}
@@ -443,10 +443,10 @@ class BonusController extends Controller
return DB::table('history')
->select('history.seedtime')->distinct()
->join('torrents', 'torrents.info_hash', '=', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 2)
->where('history.seedtime', '<', 2592000 * 3)
->where('history.user_id', '=', $user->id)
->where('history.user_id', $user->id)
->count();
}
@@ -464,10 +464,10 @@ class BonusController extends Controller
return DB::table('history')
->select('history.seedtime')->distinct()
->join('torrents', 'torrents.info_hash', '=', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 3)
->where('history.seedtime', '<', 2592000 * 6)
->where('history.user_id', '=', $user->id)
->where('history.user_id', $user->id)
->count();
}
@@ -485,10 +485,10 @@ class BonusController extends Controller
return DB::table('history')
->select('history.seedtime')->distinct()
->join('torrents', 'torrents.info_hash', '=', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 6)
->where('history.seedtime', '<', 2592000 * 12)
->where('history.user_id', '=', $user->id)
->where('history.user_id', $user->id)
->count();
}
@@ -506,9 +506,9 @@ class BonusController extends Controller
return DB::table('history')
->select('history.seedtime')->distinct()
->join('torrents', 'torrents.info_hash', '=', 'history.info_hash')
->where('history.active', '=', 1)
->where('history.active', 1)
->where('history.seedtime', '>=', 2592000 * 12)
->where('history.user_id', '=', $user->id)
->where('history.user_id', $user->id)
->count();
}
}
+1 -1
View File
@@ -31,7 +31,7 @@ class BugController extends Controller
public function bug(Request $request)
{
// Fetch owner account
$user = User::where('id', '=', '3')->first();
$user = User::where('id', 3)->first();
if ($request->isMethod('POST')) {
$input = $request->all();
+2 -2
View File
@@ -44,7 +44,7 @@ class CatalogController extends Controller
{
$user = auth()->user();
$catalog = Catalog::findOrFail($id);
$records = CatalogTorrent::where('catalog_id', '=', $id)->orderBy('imdb', 'DESC')->get();
$records = CatalogTorrent::where('catalog_id', $id)->latest('imdb')->get();
return view('catalogs.catalog', ['user' => $user, 'catalog' => $catalog, 'records' => $records]);
}
@@ -60,7 +60,7 @@ class CatalogController extends Controller
public function torrents($imdb)
{
$user = auth()->user();
$torrents = Torrent::where('imdb', '=', $imdb)->orderBy('size', 'DESC')->get();
$torrents = Torrent::where('imdb', $imdb)->latest('size')->get();
return view('catalogs.torrents', ['torrents' => $torrents, 'user' => $user]);
}
+8 -8
View File
@@ -65,7 +65,7 @@ class ForumController extends Controller
*/
public function index()
{
$categories = Forum::orderBy('position', 'ASC')->get();
$categories = Forum::oldest('position')->get();
// Total Forums Count
$num_forums = Forum::all()->count();
// Total Posts Count
@@ -115,7 +115,7 @@ class ForumController extends Controller
}
// Fetch topics->posts in descending order
$topics = $forum->topics()->orderBy('pinned', 'DESC')->orderBy('last_reply_at', 'DESC')->latest()->paginate(25);
$topics = $forum->topics()->latest('pinned')->latest('last_reply_at')->latest()->paginate(25);
return view('forum.display', ['forum' => $forum, 'topics' => $topics, 'category' => $category]);
}
@@ -143,7 +143,7 @@ class ForumController extends Controller
$posts = $topic->posts()->paginate(25);
// First post
$firstPost = Post::where('topic_id', '=', $topic->id)->first();
$firstPost = Post::where('topic_id', $topic->id)->first();
// The user can post a topic here ?
if ($category->getPermission()->read_topic != true) {
@@ -193,7 +193,7 @@ class ForumController extends Controller
$topic->last_post_user_id = $user->id;
$topic->last_post_user_username = $user->username;
// Count post in topic
$topic->num_post = Post::where('topic_id', '=', $topic->id)->count();
$topic->num_post = Post::where('topic_id', $topic->id)->count();
// Update time
$topic->last_reply_at = $post->created_at;
// Save
@@ -620,8 +620,8 @@ class ForumController extends Controller
{
$post = Post::findOrFail($postId);
$user = auth()->user();
$like = $user->likes()->where('post_id', '=', $post->id)->where('like', '=', 1)->first();
$dislike = $user->likes()->where('post_id', '=', $post->id)->where('dislike', '=', 1)->first();
$like = $user->likes()->where('post_id', $post->id)->where('like', 1)->first();
$dislike = $user->likes()->where('post_id', $post->id)->where('dislike', 1)->first();
if ($like || $dislike) {
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])->with(Toastr::error('You have already liked/disliked this post!', 'Bro', ['options']));
@@ -642,8 +642,8 @@ class ForumController extends Controller
{
$post = Post::findOrFail($postId);
$user = auth()->user();
$like = $user->likes()->where('post_id', '=', $post->id)->where('like', '=', 1)->first();
$dislike = $user->likes()->where('post_id', '=', $post->id)->where('dislike', '=', 1)->first();
$like = $user->likes()->where('post_id', $post->id)->where('like', 1)->first();
$dislike = $user->likes()->where('post_id', $post->id)->where('dislike', 1)->first();
if ($like || $dislike) {
return redirect()->route('forum_topic', ['slug' => $post->topic->slug, 'id' => $post->topic->id])->with(Toastr::error('You have already liked/disliked this post!', 'Bro', ['options']));
+3 -3
View File
@@ -32,8 +32,8 @@ class GraveyardController extends Controller
public function index()
{
$user = auth()->user();
$dead = Torrent::where('seeders', '=', '0')->orderBy('leechers', 'desc')->paginate(50);
$deadcount = Torrent::where('seeders', '=', '0')->count();
$dead = Torrent::where('seeders', 0)->latest('leechers')->paginate(50);
$deadcount = Torrent::where('seeders', 0)->count();
$time = config('graveyard.time');
$tokens = config('graveyard.reward');
@@ -44,7 +44,7 @@ class GraveyardController extends Controller
{
$user = auth()->user();
$torrent = Torrent::findOrFail($id);
$resurrected = Graveyard::where('torrent_id', '=', $torrent->id)->first();
$resurrected = Graveyard::where('torrent_id', $torrent->id)->first();
if ($resurrected) {
return redirect()->route('graveyard')->with(Toastr::error('Torrent Resurrection Failed! This torrent is already pending a resurrection.', 'Whoops!', ['options']));
}
+8 -8
View File
@@ -39,11 +39,11 @@ class HomeController extends Controller
$articles = Article::latest()->take(1)->get(); // Fetch latest articles
// Latest Torrents Block
$torrents = Torrent::where('sd', '=', 0)->latest()->take(5)->get(); // Fetch latest torrents
$best = Torrent::where('sd', '=', 0)->orderBy('seeders', 'desc')->take(5)->get(); // Fetch Top Seeded Torrents
$leeched = Torrent::where('sd', '=', 0)->orderBy('leechers', 'desc')->take(5)->get(); // Fetch Top Leeched Torrents
$dying = Torrent::where('sd', '=', 0)->where('seeders', '=', '1')->where('times_completed', '>=', '1')->orderBy('leechers', 'desc')->take(5)->get(); // Fetch Top Dying Torrents
$dead = Torrent::where('sd', '=', 0)->where('seeders', '=', '0')->orderBy('leechers', 'desc')->take(5)->get(); // Fetch Top Dead Torrents
$torrents = Torrent::where('sd', 0)->latest()->take(5)->get(); // Fetch latest torrents
$best = Torrent::where('sd', 0)->latest('seeders')->take(5)->get(); // Fetch Top Seeded Torrents
$leeched = Torrent::where('sd', 0)->latest('leechers')->take(5)->get(); // Fetch Top Leeched Torrents
$dying = Torrent::where('sd', 0)->where('seeders', 1)->where('times_completed', '>=', '1')->latest('leechers')->take(5)->get(); // Fetch Top Dying Torrents
$dead = Torrent::where('sd', 0)->where('seeders', 0)->latest('leechers')->take(5)->get(); // Fetch Top Dead Torrents
// Latest Topics Block
$topics = Topic::latest()->take(5)->get(); // Fetch latest topics
@@ -55,8 +55,8 @@ class HomeController extends Controller
$shoutboxMessages = ShoutboxController::getMessages()['data'];
//Online Block
$user = User::orderBy('username', 'asc')->get();
$groups = Group::orderBy('position', 'asc')->get();
$user = User::oldest('username')->get();
$groups = Group::oldest('position')->get();
//Featured Torrents
$featured = FeaturedTorrent::with('torrent')->get();
@@ -75,7 +75,7 @@ class HomeController extends Controller
public function contact(Request $request)
{
// Fetch owner account
$user = User::where('id', '=', '3')->first();
$user = User::where('id', 3)->first();
if ($request->isMethod('POST')) {
$input = $request->all();
+2 -2
View File
@@ -45,8 +45,8 @@ class InviteController extends Controller
if ($invites_restricted && !in_array($user->group->name, $invite_groups)) {
return redirect()->route('invite')->with(Toastr::error('Invites are currently disabled for your userclass.', 'Whoops!', ['options']));
}
$exsist = Invite::where('email', '=', $request->input('email'))->first();
$member = User::where('email', '=', $request->input('email'))->first();
$exsist = Invite::where('email', $request->input('email'))->first();
$member = User::where('email', $request->input('email'))->first();
if ($exsist || $member) {
return redirect()->route('invite')->with(Toastr::error('The email address your trying to send a invite to has already been sent one or is a user already.', 'Whoops!', ['options']));
}
+2 -2
View File
@@ -38,7 +38,7 @@ class PageController extends Controller
*/
public function staff()
{
$staff = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_admin', '=', '1')->orWhere('groups.is_modo', '=', '1')->get();
$staff = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_admin', 1)->orWhere('groups.is_modo', 1)->get();
return view('page.staff', ['staff' => $staff]);
}
@@ -50,7 +50,7 @@ class PageController extends Controller
*/
public function internal()
{
$internal = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_internal', '=', '1')->get();
$internal = DB::table('users')->leftJoin('groups', 'users.group_id', '=', 'groups.id')->select('users.id', 'users.title', 'users.username', 'groups.name', 'groups.color', 'groups.icon')->where('groups.is_internal', 1)->get();
return view('page.internal', ['internal' => $internal]);
}
+1 -1
View File
@@ -58,7 +58,7 @@ class PollController extends Controller
Option::findOrFail($option)->increment('votes');
}
if (Voter::where('user_id', '=', $user->id)->where('poll_id', '=', $poll->id)->exists()) {
if (Voter::where('user_id', $user->id)->where('poll_id', $poll->id)->exists()) {
Toastr::error('Bro have already vote on this poll. Your vote has not been counted.', 'Whoops!', ['options']);
return redirect('poll/' . $poll->slug . '/result');
@@ -32,7 +32,7 @@ class PrivateMessageController extends Controller
{
$user = auth()->user();
$search = $request->input('subject');
$pms = PrivateMessage::where('reciever_id', '=', $request->user()->id)->where([
$pms = PrivateMessage::where('reciever_id', $request->user()->id)->where([
['subject', 'like', '%' . $search . '%'],
])->latest()->paginate(20);
@@ -49,7 +49,7 @@ class PrivateMessageController extends Controller
public function getPrivateMessages(Request $request, $username, $id)
{
$user = auth()->user();
$pms = PrivateMessage::where('reciever_id', '=', $request->user()->id)->latest()->paginate(25);
$pms = PrivateMessage::where('reciever_id', $request->user()->id)->latest()->paginate(25);
return view('pm.inbox', ['pms' => $pms, 'user' => $user]);
}
@@ -57,7 +57,7 @@ class PrivateMessageController extends Controller
public function markAllAsRead(Request $request, $username, $id)
{
$user = auth()->user();
$pms = PrivateMessage::where('reciever_id', '=', $request->user()->id)->get();
$pms = PrivateMessage::where('reciever_id', $request->user()->id)->get();
foreach ($pms as $pm) {
$pm->read = 1;
$pm->save();
@@ -113,7 +113,7 @@ class PrivateMessageController extends Controller
public function makePrivateMessage($username, $id)
{
$user = auth()->user();
$usernames = User::orderBy('username', 'ASC')->get();
$usernames = User::oldest('username')->get();
return view('pm.send', ['usernames' => $usernames, 'user' => $user]);
}
+5 -5
View File
@@ -187,9 +187,9 @@ class RequestController extends Controller
// Find the torrent in the database
$torrentRequest = TorrentRequest::findOrFail($id);
$user = auth()->user();
$requestClaim = TorrentRequestClaim::where('request_id', '=', $id)->first();
$requestClaim = TorrentRequestClaim::where('request_id', $id)->first();
$voters = $torrentRequest->requestBounty()->get();
$comments = $torrentRequest->comments()->orderBy('created_at', 'DESC')->paginate(6);
$comments = $torrentRequest->comments()->latest('created_at')->paginate(6);
$carbon = Carbon::now()->addDay();
$client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb'));
if ($torrentRequest->category_id == 2) {
@@ -410,7 +410,7 @@ class RequestController extends Controller
]);
if ($v->passes()) {
$torrent = Torrent::where('info_hash', '=', $request->input('info_hash'))->firstOrFail();
$torrent = Torrent::where('info_hash', $request->input('info_hash'))->firstOrFail();
if ($user->id == $torrent->user_id) {
$this->addRequestModeration($request->input('request_id'), $request->input('info_hash'));
@@ -586,11 +586,11 @@ class RequestController extends Controller
{
$user = auth()->user();
$torrentRequest = TorrentRequest::findOrFail($id);
$claimer = TorrentRequestClaim::where('request_id', '=', $id)->first();
$claimer = TorrentRequestClaim::where('request_id', $id)->first();
if ($user->group->is_modo || $user->username == $claimer->username) {
if ($torrentRequest->claimed == 1) {
$requestClaim = TorrentRequestClaim::where('request_id', '=', $id)->firstOrFail();
$requestClaim = TorrentRequestClaim::where('request_id', $id)->firstOrFail();
$requestClaim->delete();
$torrentRequest->claimed = null;
+3 -3
View File
@@ -28,7 +28,7 @@ class RssController extends Controller
private function auth($passkey)
{
$id = User::select('id')->where('rsskey', '=', $passkey)->first();
$id = User::select('id')->where('rsskey', $passkey)->first();
if ($user) {
$this->userID = $id;
@@ -40,7 +40,7 @@ class RssController extends Controller
private function getUserData()
{
$catArray = Rss::select('category')->where('user_id', '=', $this->userID)->first();
$catArray = Rss::select('category')->where('user_id', $this->userID)->first();
if ($catArray) {
return explode(',', $catArray);
@@ -91,7 +91,7 @@ class RssController extends Controller
{
$user = auth()->user();
$rssData = RSS::select('category')->where('user_id', '=', $user->id)->first();
$rssData = RSS::select('category')->where('user_id', $user->id)->first();
$category = Category::select('id', 'name')->get();
}
+3 -3
View File
@@ -31,7 +31,7 @@ class ShoutboxController extends Controller
public function send(Request $request)
{
$string = $request->input('message');
$checkSendRate = Shoutbox::where('user', '=', auth()->user()->id)->where('created_at', '>=', Carbon::now()->subSeconds(1))->first();
$checkSendRate = Shoutbox::where('user', auth()->user()->id)->where('created_at', '>=', Carbon::now()->subSeconds(1))->first();
if ($checkSendRate) {
return 'Wait 1 Seconds Between Posts Please';
}
@@ -96,7 +96,7 @@ class ShoutboxController extends Controller
public static function getMessages($after = null)
{
$messages = cache()->remember('shoutbox_messages', 7200, function () {
return Shoutbox::orderBy('id', 'desc')->take(150)->get();
return Shoutbox::latest('id')->take(150)->get();
});
$messages = $messages->reverse();
@@ -212,7 +212,7 @@ class ShoutboxController extends Controller
{
$shout = Shoutbox::find($id);
if (auth()->user()->group->is_modo || auth()->user()->id == $shout->poster->id) {
Shoutbox::where('id', '=', $id)->delete();
Shoutbox::where('id', $id)->delete();
cache()->forget('shoutbox_messages');
return redirect()->route('home')->with(Toastr::success('Shout Has Been Deleted.', 'Yay!', ['options']));
} else {
@@ -28,7 +28,7 @@ class CatalogController extends Controller
*/
public function getCatalogs()
{
$catalogs = Catalog::orderBy('name', 'ASC')->get();
$catalogs = Catalog::latest('name')->get();
return view('Staff.catalog.catalogs', ['catalogs' => $catalogs]);
}
@@ -38,7 +38,7 @@ class CatalogController extends Controller
$v = validator($request->all(), [
'catalog' => 'required|min:3|max:20|regex:/^[(a-zA-Z\-)]+$/u'
]);
$catalog = Catalog::where('name', '=', $request->input('catalog'))->first();
$catalog = Catalog::where('name', $request->input('catalog'))->first();
if ($catalog) {
return redirect()->route('catalogs')->with(Toastr::error('Catalog ' . $catalog->name . ' is already in database', 'Whoops!', ['options']));
}
@@ -82,7 +82,7 @@ class CatalogController extends Controller
*/
public function getCatalogTorrent()
{
$catalogs = Catalog::orderBy('name', 'ASC')->get();
$catalogs = Catalog::latest('name')->get();
return view('Staff.catalog.catalog_torrent')->with('catalogs', $catalogs);
}
@@ -96,7 +96,7 @@ class CatalogController extends Controller
'tvdb' => 'required|numeric',
'catalog_id' => 'required|numeric|exists:catalog_id'
]);
$torrent = CatalogTorrent::where('imdb', '=', $request->input('imdb'))->first();
$torrent = CatalogTorrent::where('imdb', $request->input('imdb'))->first();
if ($torrent) {
return redirect()->route('getCatalogTorrent')->with(Toastr::error('IMDB# ' . $torrent->imdb . ' is already in database', 'Whoops!', ['options']));
}
@@ -105,7 +105,7 @@ class CatalogController extends Controller
$torrent->catalog_id = $request->input('catalog_id');
$torrent->save();
// Count and save the torrent number in this catalog
$catalog->num_torrent = CatalogTorrent::where('catalog_id', '=', $catalog->id)->count();
$catalog->num_torrent = CatalogTorrent::where('catalog_id', $catalog->id)->count();
$catalog->save();
return redirect()->route('getCatalogTorrent')->with(Toastr::success('IMDB# ' . $request->input('imdb') . ' has been successfully added', 'Yay!', ['options']));
}
@@ -114,7 +114,7 @@ class CatalogController extends Controller
public function getCatalogRecords($catalog_id)
{
$catalogs = Catalog::findOrFail($catalog_id);
$records = CatalogTorrent::where('catalog_id', '=', $catalog_id)->orderBy('imdb', 'DESC')->get();
$records = CatalogTorrent::where('catalog_id', $catalog_id)->latest('imdb')->get();
return view('Staff.catalog.catalog_records', ['catalog' => $catalogs, 'records' => $records]);
}
}
@@ -29,7 +29,7 @@ class FlushController extends Controller
// Deleting old peers from the database
foreach (Peer::all() as $peer) {
if ((time() - strtotime($peer->updated_at)) > (60 * 60)) {
$history = History::where("info_hash", "=", $peer->info_hash)->where("user_id", "=", $peer->user_id)->first();
$history = History::where("info_hash", $peer->info_hash)->where("user_id", $peer->user_id)->first();
if ($history) {
$history->active = false;
$history->save();
@@ -27,7 +27,7 @@ class ForumController extends Controller
*/
public function index()
{
$categories = Forum::where('parent_id', '=', 0)->get();
$categories = Forum::where('parent_id', 0)->get();
return view('Staff.forum.index', ['categories' => $categories]);
}
@@ -38,7 +38,7 @@ class ForumController extends Controller
*/
public function add(Request $request)
{
$categories = Forum::where('parent_id', '=', 0)->get();
$categories = Forum::where('parent_id', 0)->get();
$groups = Group::all();
if ($request->isMethod('POST')) {
$parentForum = Forum::findOrFail($request->input('parent_id'));
@@ -88,7 +88,7 @@ class ForumController extends Controller
*/
public function edit(Request $request, $slug, $id)
{
$categories = Forum::where('parent_id', '=', 0)->get();
$categories = Forum::where('parent_id', 0)->get();
$groups = Group::all();
$forum = Forum::findOrFail($id);
if ($request->isMethod('POST')) {
@@ -141,7 +141,7 @@ class ForumController extends Controller
// Forum to delete
$forum = Forum::findOrFail($id);
$permissions = Permission::where('forum_id', '=', $forum->id)->get();
$permissions = Permission::where('forum_id', $forum->id)->get();
foreach ($permissions as $p) {
$p->delete();
}
@@ -149,14 +149,14 @@ class ForumController extends Controller
if ($forum->parent_id == 0) {
$category = $forum;
$permissions = Permission::where('forum_id', '=', $category->id)->get();
$permissions = Permission::where('forum_id', $category->id)->get();
foreach ($permissions as $p) {
$p->delete();
}
$forums = $category->getForumsInCategory();
foreach ($forums as $forum) {
$permissions = Permission::where('forum_id', '=', $forum->id)->get();
$permissions = Permission::where('forum_id', $forum->id)->get();
foreach ($permissions as $p) {
$p->delete();
}
@@ -171,7 +171,7 @@ class ForumController extends Controller
}
$category->delete();
} else {
$permissions = Permission::where('forum_id', '=', $forum->id)->get();
$permissions = Permission::where('forum_id', $forum->id)->get();
foreach ($permissions as $p) {
$p->delete();
}
@@ -27,7 +27,7 @@ class GiftController extends Controller
*/
public function index()
{
$users = User::orderBy('username', 'ASC')->get();
$users = User::oldest('username')->get();
return view('Staff.gift.index', compact('users'));
}
@@ -32,24 +32,24 @@ class HomeController extends Controller
{
//User Info
$num_user = User::all()->count();
$banned = User::where('group_id', '=', '5')->count();
$validating = User::where('group_id', '=', '1')->count();
$banned = User::where('group_id', 5)->count();
$validating = User::where('group_id', 1)->count();
//Torrent Info
$num_torrent = Torrent::all()->count();
$pending = Torrent::pending()->count();
$rejected = Torrent::rejected()->count();
//Peers Info
$peers = Peer::all()->count();
$seeders = Peer::where('seeder', '=', '1')->count();
$leechers = Peer::where('seeder', '=', '0')->count();
$seeders = Peer::where('seeder', 1)->count();
$leechers = Peer::where('seeder', 0)->count();
//Seedbox Info
$seedboxes = Client::all()->count();
$highspeed_users = Client::all()->count();
$highspeed_torrents = Torrent::where('highspeed', '=', '1')->count();
$highspeed_torrents = Torrent::where('highspeed', 1)->count();
//User Info
$reports = Report::all()->count();
$unsolved = Report::where('solved', '=', '0')->count();
$solved = Report::where('solved', '=', '1')->count();
$unsolved = Report::where('solved', 0)->count();
$solved = Report::where('solved', 1)->count();
//Polls
$pollCount = Poll::count();
@@ -34,7 +34,7 @@ class ModerationController extends Controller
$pending = Torrent::pending()->get();
$postponed = Torrent::postponed()->get();
$rejected = Torrent::rejected()->get();
$modder = Torrent::where('status', '=', '0')->count();
$modder = Torrent::where('status', 0)->count();
return view('Staff.torrent.moderation', compact(['current', 'pending', 'postponed', 'rejected', 'modder']));
}
+17 -17
View File
@@ -39,10 +39,10 @@ class UserController extends Controller
public function members()
{
$users = User::latest()->paginate(25);
$uploaders = User::where('group_id', '=', 7)->latest()->paginate(25);
$mods = User::where('group_id', '=', 6)->latest()->paginate(25);
$admins = User::where('group_id', '=', 4)->latest()->paginate(25);
$coders = User::where('group_id', '=', 10)->latest()->paginate(25);
$uploaders = User::where('group_id', 7)->latest()->paginate(25);
$mods = User::where('group_id', 6)->latest()->paginate(25);
$admins = User::where('group_id', 4)->latest()->paginate(25);
$coders = User::where('group_id', 10)->latest()->paginate(25);
return view('Staff.user.user_search', ['users' => $users, 'uploaders' => $uploaders, 'mods' => $mods, 'admins' => $admins, 'coders' => $coders]);
}
@@ -73,7 +73,7 @@ class UserController extends Controller
{
$user = User::findOrFail($id);
$groups = Group::all();
$notes = Note::where('user_id', '=', $id)->latest()->paginate(25);
$notes = Note::where('user_id', $id)->latest()->paginate(25);
return view('Staff.user.user_edit', ['user' => $user, 'groups' => $groups, 'notes' => $notes]);
}
@@ -173,58 +173,58 @@ class UserController extends Controller
return redirect()->route('home')->with(Toastr::error('You Cannot Delete Yourself Or Other Staff', 'Whoops!', ['options']));
} else {
// Removes UserID from Torrents if any and replaces with System UserID (0)
foreach (Torrent::where('user_id', '=', $user->id)->get() as $tor) {
foreach (Torrent::where('user_id', $user->id)->get() as $tor) {
$tor->user_id = 1;
$tor->save();
}
// Removes UserID from Comments if any and replaces with System UserID (0)
foreach (Comment::where('user_id', '=', $user->id)->get() as $com) {
foreach (Comment::where('user_id', $user->id)->get() as $com) {
$com->user_id = 1;
$com->save();
}
// Removes UserID from Posts if any and replaces with System UserID (0)
foreach (Post::where('user_id', '=', $user->id)->get() as $post) {
foreach (Post::where('user_id', $user->id)->get() as $post) {
$post->user_id = 1;
$post->save();
}
// Removes UserID from Topic Creators if any and replaces with System UserID (0)
foreach (Topic::where('first_post_user_id', '=', $user->id)->get() as $topic) {
foreach (Topic::where('first_post_user_id', $user->id)->get() as $topic) {
$topic->first_post_user_id = 1;
$topic->save();
}
// Removes UserID from Topic if any and replaces with System UserID (0)
foreach (Topic::where('last_post_user_id', '=', $user->id)->get() as $topic) {
foreach (Topic::where('last_post_user_id', $user->id)->get() as $topic) {
$topic->last_post_user_id = 1;
$topic->save();
}
// Removes UserID from PM if any and replaces with System UserID (0)
foreach (PrivateMessage::where('sender_id', '=', $user->id)->get() as $sent) {
foreach (PrivateMessage::where('sender_id', $user->id)->get() as $sent) {
$sent->sender_id = 1;
$sent->save();
}
// Removes UserID from PM if any and replaces with System UserID (0)
foreach (PrivateMessage::where('reciever_id', '=', $user->id)->get() as $recieved) {
foreach (PrivateMessage::where('reciever_id', $user->id)->get() as $recieved) {
$recieved->reciever_id = 1;
$recieved->save();
}
// Removes all Posts made by User from the shoutbox
foreach (Shoutbox::where('user', '=', $user->id)->get() as $shout) {
foreach (Shoutbox::where('user', $user->id)->get() as $shout) {
$shout->delete();
}
// Removes all notes for user
foreach (Note::where('user_id', '=', $user->id)->get() as $note) {
foreach (Note::where('user_id', $user->id)->get() as $note) {
$note->delete();
}
// Removes all likes for user
foreach (Like::where('user_id', '=', $user->id)->get() as $like) {
foreach (Like::where('user_id', $user->id)->get() as $like) {
$like->delete();
}
// Removes all thanks for user
foreach (Thank::where('user_id', '=', $user->id)->get() as $thank) {
foreach (Thank::where('user_id', $user->id)->get() as $thank) {
$thank->delete();
}
// Removes all follows for user
foreach (Follow::where('user_id', '=', $user->id)->get() as $follow) {
foreach (Follow::where('user_id', $user->id)->get() as $follow) {
$follow->delete();
}
@@ -25,7 +25,7 @@ class WarningController extends Controller
public function getWarnings()
{
$warnings = Warning::with(['torrenttitle', 'warneduser'])->latest()->paginate(25);
$warningcount = Warning::where('active', '=', 1)->count();
$warningcount = Warning::where('active', 1)->count();
return view('Staff.warnings.index', ['warnings' => $warnings, 'warningcount' => $warningcount]);
}
+22 -22
View File
@@ -46,27 +46,27 @@ class StatsController extends Controller
});
// Total Movies Count
$num_movies = cache()->remember('num_movies', 60, function () {
return Torrent::where('category_id', '1')->count();
return Torrent::where('category_id', 1)->count();
});
// Total HDTV Count
$num_hdtv = cache()->remember('num_hdtv', 60, function () {
return Torrent::where('category_id', '2')->count();
return Torrent::where('category_id', 2)->count();
});
// Total FANRES Count
$num_fan = cache()->remember('num_fan', 60, function () {
return Torrent::where('category_id', '3')->count();
return Torrent::where('category_id', 3)->count();
});
// Total SD Count
$num_sd = cache()->remember('num_sd', 60, function () {
return Torrent::where('sd', '1')->count();
return Torrent::where('sd', 1)->count();
});
// Total Seeders
$num_seeders = cache()->remember('num_seeders', 60, function () {
return Peer::where('seeder', '1')->count();
return Peer::where('seeder', 1)->count();
});
// Total Leechers
$num_leechers = cache()->remember('num_leechers', 60, function () {
return Peer::where('seeder', '0')->count();
return Peer::where('seeder', 0)->count();
});
// Total Peers
$num_peers = cache()->remember('num_peers', 60, function () {
@@ -102,7 +102,7 @@ class StatsController extends Controller
public function uploaded()
{
// Fetch Top Uploaders
$uploaded = User::orderBy('uploaded', 'DESC')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$uploaded = User::latest('uploaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
return view('stats.users.uploaded', ['uploaded' => $uploaded]);
}
@@ -110,7 +110,7 @@ class StatsController extends Controller
public function downloaded()
{
// Fetch Top Downloaders
$downloaded = User::orderBy('downloaded', 'DESC')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$downloaded = User::latest('downloaded')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
return view('stats.users.downloaded', ['downloaded' => $downloaded]);
}
@@ -118,7 +118,7 @@ class StatsController extends Controller
public function seeders()
{
// Fetch Top Seeders
$seeders = Peer::with('user')->select(DB::raw('user_id, count(*) as value'))->where('seeder', '=', '1')->groupBy('user_id')->orderBy('value', 'DESC')->take(100)->get();
$seeders = Peer::with('user')->select(DB::raw('user_id, count(*) as value'))->where('seeder', 1)->groupBy('user_id')->latest('value')->take(100)->get();
return view('stats.users.seeders', ['seeders' => $seeders]);
}
@@ -126,7 +126,7 @@ class StatsController extends Controller
public function leechers()
{
// Fetch Top Leechers
$leechers = Peer::with('user')->select(DB::raw('user_id, count(*) as value'))->where('seeder', '=', '0')->groupBy('user_id')->orderBy('value', 'DESC')->take(100)->get();
$leechers = Peer::with('user')->select(DB::raw('user_id, count(*) as value'))->where('seeder', 0)->groupBy('user_id')->latest('value')->take(100)->get();
return view('stats.users.leechers', ['leechers' => $leechers]);
}
@@ -134,7 +134,7 @@ class StatsController extends Controller
public function uploaders()
{
// Fetch Top Uploaders
$uploaders = Torrent::with('user')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->orderBy('value', 'DESC')->take(100)->get();
$uploaders = Torrent::with('user')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(100)->get();
return view('stats.users.uploaders', ['uploaders' => $uploaders]);
}
@@ -142,7 +142,7 @@ class StatsController extends Controller
public function bankers()
{
// Fetch Top Bankers
$bankers = User::orderBy('seedbonus', 'DESC')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
$bankers = User::latest('seedbonus')->where('group_id', '!=', 1)->where('group_id', '!=', 5)->take(100)->get();
return view('stats.users.bankers', ['bankers' => $bankers]);
}
@@ -150,7 +150,7 @@ class StatsController extends Controller
public function seedtime()
{
// Fetch Top Total Seedtime
$seedtime = User::with('history')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->orderBy('value', 'DESC')->take(100)->sum('seedtime');
$seedtime = User::with('history')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(100)->sum('seedtime');
return view('stats.users.seedtime', ['seedtime' => $seedtime]);
}
@@ -158,7 +158,7 @@ class StatsController extends Controller
public function seedsize()
{
// Fetch Top Total Seedsize Users
$seedsize = User::with('peers', 'torrents')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->orderBy('value', 'DESC')->take(100)->sum('size');
$seedsize = User::with('peers', 'torrents')->select(DB::raw('user_id, count(*) as value'))->groupBy('user_id')->latest('value')->take(100)->sum('size');
return view('stats.users.seedsize', ['seedsize' => $seedsize]);
}
@@ -167,7 +167,7 @@ class StatsController extends Controller
public function seeded()
{
// Fetch Top Seeded
$seeded = Torrent::orderBy('seeders', 'DESC')->take(100)->get();
$seeded = Torrent::latest('seeders')->take(100)->get();
return view('stats.torrents.seeded', ['seeded' => $seeded]);
}
@@ -175,7 +175,7 @@ class StatsController extends Controller
public function leeched()
{
// Fetch Top Leeched
$leeched = Torrent::orderBy('leechers', 'DESC')->take(100)->get();
$leeched = Torrent::latest('leechers')->take(100)->get();
return view('stats.torrents.leeched', ['leeched' => $leeched]);
}
@@ -183,7 +183,7 @@ class StatsController extends Controller
public function completed()
{
// Fetch Top Completed
$completed = Torrent::orderBy('times_completed', 'DESC')->take(100)->get();
$completed = Torrent::latest('times_completed')->take(100)->get();
return view('stats.torrents.completed', ['completed' => $completed]);
}
@@ -191,7 +191,7 @@ class StatsController extends Controller
public function dying()
{
// Fetch Top Dying
$dying = Torrent::where('seeders', '=', '1')->where('times_completed', '>=', '1')->orderBy('leechers', 'DESC')->take(100)->get();
$dying = Torrent::where('seeders', 1)->where('times_completed', '>=', '1')->latest('leechers')->take(100)->get();
return view('stats.torrents.dying', ['dying' => $dying]);
}
@@ -199,7 +199,7 @@ class StatsController extends Controller
public function dead()
{
// Fetch Top Dead
$dead = Torrent::where('seeders', '=', '0')->orderBy('leechers', 'DESC')->take(100)->get();
$dead = Torrent::where('seeders', 0)->latest('leechers')->take(100)->get();
return view('stats.torrents.dead', ['dead' => $dead]);
}
@@ -208,7 +208,7 @@ class StatsController extends Controller
public function bountied()
{
// Fetch Top Bountied
$bountied = TorrentRequest::orderBy('bounty', 'DESC')->take(100)->get();
$bountied = TorrentRequest::latest('bounty')->take(100)->get();
return view('stats.requests.bountied', ['bountied' => $bountied]);
}
@@ -217,7 +217,7 @@ class StatsController extends Controller
public function groups()
{
// Fetch Groups User Counts
$groups = Group::orderBy('position', 'asc')->get();
$groups = Group::oldest('position')->get();
return view('stats.groups.groups', ['groups' => $groups]);
}
@@ -226,7 +226,7 @@ class StatsController extends Controller
{
// Fetch Users In Group
$group = Group::findOrFail($id);
$users = User::where('group_id', '=', $group->id)->latest()->paginate(100);
$users = User::where('group_id', $group->id)->latest()->paginate(100);
return view('stats.groups.group', ['users' => $users, 'group' => $group]);
}
+1 -1
View File
@@ -30,7 +30,7 @@ class ThankController extends Controller
$user = auth()->user();
$torrent = Torrent::findOrFail($id);
$thank = Thank::where('user_id', '=', $user->id)->where('torrent_id', '=', $torrent->id)->first();
$thank = Thank::where('user_id', $user->id)->where('torrent_id', $torrent->id)->first();
if ($thank) {
return redirect()->route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::error('You Have Already Thanked On This Torrent!', 'Whoops!', ['options']));
}
+25 -25
View File
@@ -89,8 +89,8 @@ class TorrentController extends Controller
$type = $request->input('type');
$torrents = Torrent::where([
['name', 'like', '%' . $name . '%'],
['category_id', '=', $category_id],
['type', '=', $type],
['category_id', $category_id],
['type', $type],
])->orderBy($order[0], $order[1])->paginate(25);
$torrents->setPath('?name=' . $name . '&category_id=' . $category_id . '&type=' . $type . '&order=' . $order[0] . '%3A' . $order[1]);
@@ -276,7 +276,7 @@ class TorrentController extends Controller
$torrent->save();
// Count and save the torrent number in this category
$category->num_torrent = Torrent::where('category_id', '=', $category->id)->count();
$category->num_torrent = Torrent::where('category_id', $category->id)->count();
$category->save();
// Torrent Tags System
@@ -323,7 +323,7 @@ class TorrentController extends Controller
$user = auth()->user();
$torrents = Torrent::query();
$alive = Torrent::where('seeders', '>=', 1)->count();
$dead = Torrent::where('seeders', '=', 0)->count();
$dead = Torrent::where('seeders', 0)->count();
$repository = $this->repository;
return view('torrent.torrents', compact('repository', 'torrents', 'user', 'alive', 'dead'));
}
@@ -491,16 +491,16 @@ class TorrentController extends Controller
public function torrent($slug, $id)
{
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$similar = Torrent::where('imdb', '=', $torrent->imdb)->where('status', '=', 1)->orderBy('seeders', 'DESC')->get();
$similar = Torrent::where('imdb', $torrent->imdb)->where('status', 1)->latest('seeders')->get();
$uploader = $torrent->user;
$user = auth()->user();
$freeleech_token = FreeleechToken::where('user_id', '=', $user->id)->where('torrent_id', '=', $torrent->id)->first();
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
$freeleech_token = FreeleechToken::where('user_id', $user->id)->where('torrent_id', $torrent->id)->first();
$personal_freeleech = PersonalFreeleech::where('user_id', $user->id)->first();
$comments = $torrent->comments()->latest()->paginate(6);
$thanks = $torrent->thanks()->count();
$total_tips = BonTransactions::where('torrent_id', '=', $id)->sum('cost');
$user_tips = BonTransactions::where('torrent_id', '=', $id)->where('sender', '=', auth()->user()->id)->sum('cost');
$last_seed_activity = History::where('info_hash', '=', $torrent->info_hash)->where('seeder', '=', 1)->orderBy('updated_at', 'DESC')->first();
$total_tips = BonTransactions::where('torrent_id', $id)->sum('cost');
$user_tips = BonTransactions::where('torrent_id', $id)->where('sender', auth()->user()->id)->sum('cost');
$last_seed_activity = History::where('info_hash', $torrent->info_hash)->where('seeder', 1)->latest('updated_at')->first();
$client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb'));
if ($torrent->category_id == 2) {
@@ -518,7 +518,7 @@ class TorrentController extends Controller
}
if ($torrent->featured == 1) {
$featured = FeaturedTorrent::where('torrent_id', '=', $id)->first();
$featured = FeaturedTorrent::where('torrent_id', $id)->first();
} else {
$featured = null;
}
@@ -569,7 +569,7 @@ class TorrentController extends Controller
public function peers($slug, $id)
{
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$peers = Peer::where('torrent_id', '=', $id)->orderBy('seeder', 'DESC')->paginate(25); // list the peers
$peers = Peer::where('torrent_id', $id)->latest('seeder')->paginate(25); // list the peers
return view('torrent.peers', ['torrent' => $torrent, 'peers' => $peers]);
}
@@ -586,7 +586,7 @@ class TorrentController extends Controller
public function history($slug, $id)
{
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$history = History::where('info_hash', '=', $torrent->info_hash)->latest()->paginate(25);
$history = History::where('info_hash', $torrent->info_hash)->latest()->paginate(25);
return view('torrent.history', ['torrent' => $torrent, 'history' => $history]);
}
@@ -797,7 +797,7 @@ class TorrentController extends Controller
$appurl = config('app.url');
$user = auth()->user();
$torrent = Torrent::findOrFail($id);
$reseed = History::where('info_hash', '=', $torrent->info_hash)->where('active', '=', 0)->get();
$reseed = History::where('info_hash', $torrent->info_hash)->where('active', 0)->get();
if ($torrent->seeders <= 2) {
Shoutbox::create(['user' => "1", 'mentions' => "1", 'message' => "Ladies and Gents, [url={$appurl}/{$user->username}.{$user->id}]{$user->username}[/url] has requested a reseed on [url={$appurl}/torrents/{$torrent->slug}.{$torrent->id}]{$torrent->name}[/url] can you help out :question:"]);
cache()->forget('shoutbox_messages');
@@ -910,7 +910,7 @@ class TorrentController extends Controller
$torrent = Torrent::withAnyStatus()->findOrFail($id);
if ($user->group->is_modo || ($user->id == $torrent->user_id && Carbon::now()->lt($torrent->created_at->addDay()))) {
$users = History::where('info_hash', '=', $torrent->info_hash)->get();
$users = History::where('info_hash', $torrent->info_hash)->get();
foreach ($users as $pm) {
$pmuser = new PrivateMessage();
$pmuser->sender_id = 1;
@@ -926,23 +926,23 @@ class TorrentController extends Controller
\LogActivity::addToLog("Member {$user->username} has deleted torrent {$torrent->name} .");
//Remove requests
$torrentRequest = TorrentRequest::where('filled_hash', '=', $torrent->info_hash)->get();
$torrentRequest = TorrentRequest::where('filled_hash', $torrent->info_hash)->get();
foreach ($torrentRequest as $req) {
if ($req) {
Comment::where('requests_id', '=', $req->id)->delete();
TorrentRequestBounty::where('requests_id', '=', $req->id)->delete();
Comment::where('requests_id', $req->id)->delete();
TorrentRequestBounty::where('requests_id', $req->id)->delete();
$req->delete();
}
}
//Remove Torrent related info
Peer::where('torrent_id', '=', $id)->delete();
History::where('info_hash', '=', $torrent->info_hash)->delete();
Warning::where('id', '=', $id)->delete();
TorrentFile::where('torrent_id', '=', $id)->delete();
Peer::where('torrent_id', $id)->delete();
History::where('info_hash', $torrent->info_hash)->delete();
Warning::where('id', $id)->delete();
TorrentFile::where('torrent_id', $id)->delete();
if ($torrent->featured == 1) {
FeaturedTorrent::where('torrent_id', '=', $id)->delete();
FeaturedTorrent::where('torrent_id', $id)->delete();
}
Torrent::withAnyStatus()->where('id', '=', $id)->delete();
Torrent::withAnyStatus()->where('id', $id)->delete();
return redirect()->back()->with(Toastr::success('Torrent Has Been Deleted!', 'Yay!', ['options']));
}
@@ -970,7 +970,7 @@ class TorrentController extends Controller
{
$user = auth()->user();
$torrent = Torrent::withAnyStatus()->findOrFail($id);
$active_token = FreeleechToken::where('user_id', '=', $user->id)->where('torrent_id', '=', $torrent->id)->first();
$active_token = FreeleechToken::where('user_id', $user->id)->where('torrent_id', $torrent->id)->first();
if ($user->fl_tokens >= 1 && !$active_token) {
$token = new FreeleechToken();
$token->user_id = $user->id;
+15 -15
View File
@@ -80,10 +80,10 @@ class UserController extends Controller
{
$user = User::findOrFail($id);
$groups = Group::all();
$followers = Follow::where('target_id', '=', $id)->get();
$followers = Follow::where('target_id', $id)->get();
$history = $user->history;
$warnings = Warning::where('user_id', '=', $id)->whereNotNull('torrent')->where('active', '=', '1')->take(3)->get();
$hitrun = Warning::where('user_id', '=', $id)->latest()->paginate(10);
$warnings = Warning::where('user_id', $id)->whereNotNull('torrent')->where('active', 1)->take(3)->get();
$hitrun = Warning::where('user_id', $id)->latest()->paginate(10);
return view('user.profile', ['user' => $user, 'groups' => $groups, 'followers' => $followers, 'history' => $history, 'warnings' => $warnings, 'hitrun' => $hitrun]);
}
@@ -266,7 +266,7 @@ class UserController extends Controller
public function clients($username, $id)
{
$user = auth()->user();
$cli = Client::where('user_id', '=', $user->id)->get();
$cli = Client::where('user_id', $user->id)->get();
return view('user.clients', ['user' => $user, 'clients' => $cli]);
}
@@ -281,7 +281,7 @@ class UserController extends Controller
$user = auth()->user();
if ($v->passes()) {
if (Hash::check($request->input('password'), $user->password)) {
if (Client::where('user_id', '=', $user->id)->get()->count() >= config('other.max_cli')) {
if (Client::where('user_id', $user->id)->get()->count() >= config('other.max_cli')) {
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])->with(Toastr::error('Max Clients Reached!', 'Whoops!', ['options']));
}
$cli = new Client;
@@ -307,7 +307,7 @@ class UserController extends Controller
$user = auth()->user();
if ($v->passes()) {
$cli = Client::where('id', '=', $request->input('cliid'));
$cli = Client::where('id', $request->input('cliid'));
$cli->delete();
return redirect()->route('user_clients', ['username' => $user->username, 'id' => $user->id])->with(Toastr::success('Client Has Been Removed!', 'Yay!', ['options']));
} else {
@@ -319,8 +319,8 @@ class UserController extends Controller
{
if (auth()->user()->group->is_modo) {
$user = User::findOrFail($id);
$warnings = Warning::where('user_id', '=', $user->id)->with(['torrenttitle', 'warneduser'])->orderBy('active', 'DESC')->paginate(25);
$warningcount = Warning::where('user_id', '=', $id)->count();
$warnings = Warning::where('user_id', $user->id)->with(['torrenttitle', 'warneduser'])->latest('active')->paginate(25);
$warningcount = Warning::where('user_id', $id)->count();
return view('user.warninglog', ['warnings' => $warnings, 'warningcount' => $warningcount, 'user' => $user]);
} else {
@@ -348,7 +348,7 @@ class UserController extends Controller
{
$user = User::findOrFail($id);
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
$torrents = Torrent::withAnyStatus()->sortable(['created_at' => 'desc'])->where('user_id', '=', $user->id)->paginate(50);
$torrents = Torrent::withAnyStatus()->sortable(['created_at' => 'desc'])->where('user_id', $user->id)->paginate(50);
return view('user.uploads', ['user' => $user, 'torrents' => $torrents]);
} else {
abort(403, 'Unauthorized action.');
@@ -359,7 +359,7 @@ class UserController extends Controller
{
$user = User::findOrFail($id);
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
$active = Peer::sortable(['created_at' => 'desc'])->where('user_id', '=', $user->id)->with('torrent')->distinct('hash')->paginate(50);
$active = Peer::sortable(['created_at' => 'desc'])->where('user_id', $user->id)->with('torrent')->distinct('hash')->paginate(50);
return view('user.active', ['user' => $user, 'active' => $active]);
} else {
abort(403, 'Unauthorized action.');
@@ -370,11 +370,11 @@ class UserController extends Controller
{
$user = User::findOrFail($id);
if (auth()->user()->group->is_modo || auth()->user()->id == $user->id) {
$his_upl = History::where('user_id', '=', $id)->sum('actual_uploaded');
$his_upl_cre = History::where('user_id', '=', $id)->sum('uploaded');
$his_downl = History::where('user_id', '=', $id)->sum('actual_downloaded');
$his_downl_cre = History::where('user_id', '=', $id)->sum('downloaded');
$history = History::sortable(['created_at' => 'desc'])->where('user_id', '=', $user->id)->paginate(50);
$his_upl = History::where('user_id', $id)->sum('actual_uploaded');
$his_upl_cre = History::where('user_id', $id)->sum('uploaded');
$his_downl = History::where('user_id', $id)->sum('actual_downloaded');
$his_downl_cre = History::where('user_id', $id)->sum('downloaded');
$history = History::sortable(['created_at' => 'desc'])->where('user_id', $user->id)->paginate(50);
return view('user.history', ['user' => $user, 'history' => $history, 'his_upl' => $his_upl, 'his_upl_cre' => $his_upl_cre, 'his_downl' => $his_downl, 'his_downl_cre' => $his_downl_cre]);
} else {
abort(403, 'Unauthorized action.');