* Update AirportController.php Eager load `files` * Update DashboardController.php Eager load `journal` for user , and `aircraft, arr_airport, comments, dpt_airport` for last_pirep. * Update FlightController.php Eager load + `alt_airport, subfleets` (with their airlines) for flights and `current_airport` for user (though current_airport can be removed and we can base the in blade checks on `$user->curr_airport_id` to reduce db reads and model loading) * Update HomeController.php Eager load `home_airport` for users * Update PirepController.php Eager load `airline, aircraft, fares, transactions, dpt_airport, arr_airport, comments, simbrief, user with rank` for pirep details * Update ProfileController.php Eager load `airline, awards, current_airport, fields.field, home_airport, last_pirep, rank` for user * Update UserController.php Eager load `airline, current_airport, fields.field, home_airport, rank` for users and count `awards` * Update AirportController.php * Update DashboardController.php * Update PirepController.php * Update ProfileController.php * Update LatestNews.php Eager load `user` for news * Update LatestPilots.php Eager load `home_airport` for latest users * StyleFix 1 * StlyeFix 1.5 * Update SimBriefController.php Eager load airline with flight * Update SimBriefController.php * Update SimBriefController.php
60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
use App\Contracts\Controller;
|
|
use App\Models\Enums\UserState;
|
|
use App\Repositories\Criteria\WhereCriteria;
|
|
use App\Repositories\UserRepository;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Log;
|
|
use League\ISO3166\ISO3166;
|
|
use Prettus\Repository\Exceptions\RepositoryException;
|
|
|
|
class UserController extends Controller
|
|
{
|
|
private $userRepo;
|
|
|
|
/**
|
|
* @param UserRepository $userRepo
|
|
*/
|
|
public function __construct(UserRepository $userRepo)
|
|
{
|
|
$this->userRepo = $userRepo;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
*
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
$with = ['airline', 'current_airport', 'fields.field', 'home_airport', 'rank'];
|
|
$with_count = ['awards'];
|
|
|
|
$where = [];
|
|
|
|
if (setting('pilots.hide_inactive')) {
|
|
$where['state'] = UserState::ACTIVE;
|
|
}
|
|
|
|
try {
|
|
$this->userRepo->pushCriteria(new WhereCriteria($request, $where));
|
|
} catch (RepositoryException $e) {
|
|
Log::emergency($e);
|
|
}
|
|
|
|
$users = $this->userRepo
|
|
->withCount($with_count)
|
|
->with($with)
|
|
->orderBy('pilot_id', 'asc')
|
|
->paginate();
|
|
|
|
return view('users.index', [
|
|
'country' => new ISO3166(),
|
|
'users' => $users,
|
|
]);
|
|
}
|
|
}
|