@@ -8,6 +8,7 @@ use App\Http\Requests\UpdateUserRequest;
|
||||
use App\Models\Rank;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use App\Models\UserAward;
|
||||
use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
@@ -143,7 +144,7 @@ class UserController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$user = $this->userRepo
|
||||
->with(['fields', 'rank'])
|
||||
->with(['awards', 'fields', 'rank'])
|
||||
->findWithoutFail($id);
|
||||
|
||||
if (empty($user)) {
|
||||
@@ -265,6 +266,28 @@ class UserController extends Controller
|
||||
return redirect(route('admin.users.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the award from a user
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $id
|
||||
* @param mixed $award_id
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy_user_award($id, $award_id, Request $request)
|
||||
{
|
||||
$userAward = UserAward::where(['user_id' => $id, 'award_id' => $award_id]);
|
||||
if (empty($userAward)) {
|
||||
Flash::error('The user award could not be found');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$userAward->delete();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the user's API key
|
||||
*
|
||||
|
||||
@@ -61,27 +61,14 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to show() since only a single page gets shown and the template controls
|
||||
* the other items that are/aren't shown
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
|
||||
if (setting('pilots.home_hubs_only')) {
|
||||
$airports = $this->airportRepo->findWhere(['hub' => true]);
|
||||
} else {
|
||||
$airports = $this->airportRepo->all();
|
||||
}
|
||||
|
||||
$userFields = $this->userRepo->getUserFields($user);
|
||||
|
||||
return view('profile.index', [
|
||||
'acars' => $this->acarsEnabled(),
|
||||
'user' => $user,
|
||||
'airports' => $airports,
|
||||
'userFields' => $userFields,
|
||||
]);
|
||||
return $this->show(Auth::user()->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +78,8 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$user = User::with(['fields', 'fields.field'])
|
||||
/** @var \App\Models\User $user */
|
||||
$user = User::with(['awards', 'fields', 'fields.field'])
|
||||
->where('id', $id)
|
||||
->first();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user