mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-05 01:40:54 -05:00
refactor: user earnings
Use route model binding. Reduce temporary variables. Fix table styles.
This commit is contained in:
@@ -35,14 +35,10 @@ class EarningController extends Controller
|
||||
/**
|
||||
* Show Bonus Earnings System.
|
||||
*/
|
||||
public function index(Request $request, string $username): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
public function index(Request $request, User $user): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = User::where('username', '=', $username)->sole();
|
||||
|
||||
abort_unless($request->user()->is($user) || $request->user()->group->is_modo, 403);
|
||||
|
||||
$userbon = $user->getSeedbonus();
|
||||
|
||||
// These two partially-built queries are used for constructing all the other queries
|
||||
$distinctSeeds = Peer::query()
|
||||
->select(['user_id', 'torrent_id', 'seeder'])
|
||||
@@ -151,7 +147,7 @@ class EarningController extends Controller
|
||||
|
||||
return view('user.earning.index', [
|
||||
'user' => $user,
|
||||
'userbon' => $userbon,
|
||||
'bon' => $user->getSeedbonus(),
|
||||
'dying' => $dying,
|
||||
'legendary' => $legendary,
|
||||
'old' => $old,
|
||||
@@ -164,7 +160,6 @@ class EarningController extends Controller
|
||||
'mvp' => $mvp,
|
||||
'legend' => $legend,
|
||||
'total' => $total,
|
||||
'username' => $username,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user