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