Separation of Concerns + old coude cleanup
This commit is contained in:
parent
9baa249ba7
commit
620453c1e4
|
@ -29,8 +29,8 @@ class ApiKeyController extends Controller
|
||||||
{
|
{
|
||||||
$this->authorize('create', ApiKey::class);
|
$this->authorize('create', ApiKey::class);
|
||||||
|
|
||||||
$discriminator = "#" . bin2hex(openssl_random_pseudo_bytes(7));
|
$discriminator = "#" . bin2hex(random_bytes(7));
|
||||||
$secret = bin2hex(openssl_random_pseudo_bytes(32));
|
$secret = bin2hex(random_bytes(32));
|
||||||
|
|
||||||
$key = ApiKey::create([
|
$key = ApiKey::create([
|
||||||
'name' => $request->keyName,
|
'name' => $request->keyName,
|
||||||
|
|
|
@ -73,9 +73,9 @@ class BanController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
event(new UserBannedEvent($user, $ban));
|
event(new UserBannedEvent($user, $ban));
|
||||||
$request->session()->flash('success', 'User banned successfully! Ban ID: #'.$ban->id);
|
$request->session()->flash('success', 'User suspended successfully! Ban ID: #'.$ban->id);
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'User already banned!');
|
$request->session()->flash('error', 'User already suspended!');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -87,9 +87,9 @@ class BanController extends Controller
|
||||||
|
|
||||||
if (! is_null($user->bans)) {
|
if (! is_null($user->bans)) {
|
||||||
$user->bans->delete();
|
$user->bans->delete();
|
||||||
$request->session()->flash('success', 'User unbanned successfully!');
|
$request->session()->flash('success', __('User unsuspended successfully!'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'This user isn\'t banned!');
|
$request->session()->flash('error', __('This user isn\'t suspended!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
|
@ -45,9 +45,9 @@ class CommentController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($comment) {
|
if ($comment) {
|
||||||
$request->session()->flash('success', 'Comment posted! (:');
|
$request->session()->flash('success', __('Comment posted! (:'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Something went wrong while posting your comment!');
|
$request->session()->flash('error', __('Something went wrong while posting your comment!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -58,7 +58,7 @@ class CommentController extends Controller
|
||||||
$this->authorize('delete', $comment);
|
$this->authorize('delete', $comment);
|
||||||
|
|
||||||
$comment->delete();
|
$comment->delete();
|
||||||
$request->session()->flash('success', 'Comment deleted!');
|
$request->session()->flash('success', __('Comment deleted!'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ContactController extends Controller
|
||||||
$response = json_decode($verifyrequest->getBody(), true);
|
$response = json_decode($verifyrequest->getBody(), true);
|
||||||
|
|
||||||
if (! $response['success']) {
|
if (! $response['success']) {
|
||||||
$request->session()->flash('error', 'Beep beep boop... Robot? Submission failed.');
|
$request->session()->flash('error', __('Beep beep boop... Robot? Submission failed.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class ContactController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', 'Message sent successfully! We usually respond within 48 hours.');
|
$request->session()->flash('success', __('Message sent successfully! We usually respond within 48 hours.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ class DevToolsController extends Controller
|
||||||
protected function isolatedAuthorise()
|
protected function isolatedAuthorise()
|
||||||
{
|
{
|
||||||
if (! Auth::user()->can('admin.developertools.use')) {
|
if (! Auth::user()->can('admin.developertools.use')) {
|
||||||
abort(403, 'You\'re not authorized to access this page.');
|
abort(403, __('You\'re not authorized to access this page.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ class DevToolsController extends Controller
|
||||||
if (! is_null($application)) {
|
if (! is_null($application)) {
|
||||||
event(new ApplicationApprovedEvent($application));
|
event(new ApplicationApprovedEvent($application));
|
||||||
|
|
||||||
$request->session()->flash('success', 'Event dispatched! Please check the debug logs for more info');
|
$request->session()->flash('success', __('Event dispatched! Please check the debug logs for more info'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Application doesn\'t exist!');
|
$request->session()->flash('error', __('Application doesn\'t exist!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class FormController extends Controller
|
||||||
if (count($fields) == 2) {
|
if (count($fields) == 2) {
|
||||||
// form is probably empty, since forms with fields will alawys have more than 2 items
|
// form is probably empty, since forms with fields will alawys have more than 2 items
|
||||||
|
|
||||||
$request->session()->flash('error', 'Sorry, but you may not create empty forms.');
|
$request->session()->flash('error', __('Sorry, but you may not create empty forms.'));
|
||||||
|
|
||||||
return redirect()->to(route('showForms'));
|
return redirect()->to(route('showForms'));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class FormController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Form created! You can now link this form to a vacancy.');
|
$request->session()->flash('success', __('Form created! You can now link this form to a vacancy.'));
|
||||||
|
|
||||||
return redirect()->to(route('showForms'));
|
return redirect()->to(route('showForms'));
|
||||||
}
|
}
|
||||||
|
@ -92,9 +92,9 @@ class FormController extends Controller
|
||||||
if ($deletable) {
|
if ($deletable) {
|
||||||
$form->delete();
|
$form->delete();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Form deleted successfully.');
|
$request->session()->flash('success', __('Form deleted successfully.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.');
|
$request->session()->flash('error', __('You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -135,7 +135,7 @@ class FormController extends Controller
|
||||||
$form->formStructure = $contextValidation->get('structure');
|
$form->formStructure = $contextValidation->get('structure');
|
||||||
$form->save();
|
$form->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Hooray! Your form was updated. New applications for it\'s vacancy will use it.');
|
$request->session()->flash('success', __('Hooray! Your form was updated. New applications for it\'s vacancy will use it.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
$request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages());
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,15 +77,15 @@ class OptionsController extends Controller
|
||||||
report($ex);
|
report($ex);
|
||||||
|
|
||||||
$errorCond = true;
|
$errorCond = true;
|
||||||
$request->session()->flash('error', 'An error occurred while trying to save settings: '.$ex->getMessage());
|
$request->session()->flash('error', __('An error occurred while trying to save settings: :message ', ['message' => $ex->getMessage()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($errorCond)) {
|
if (! isset($errorCond)) {
|
||||||
$request->session()->flash('success', 'Settings saved successfully!');
|
$request->session()->flash('success', __('Settings saved successfully!'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'You do not have permission to update this resource.');
|
$request->session()->flash('error', __('You do not have permission to update this resource.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -103,12 +103,12 @@ class OptionsController extends Controller
|
||||||
if (!is_null($request->gamePref) && in_array($request->gamePref, $supportedGames))
|
if (!is_null($request->gamePref) && in_array($request->gamePref, $supportedGames))
|
||||||
{
|
{
|
||||||
Options::changeOption('currentGame', $request->gamePref);
|
Options::changeOption('currentGame', $request->gamePref);
|
||||||
$request->session()->flash('success', 'Updated current game.');
|
$request->session()->flash('success', __('Updated current game.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('error', 'Unsupported game ' . $request->gamePref . '.');
|
$request->session()->flash('error', __('Unsupported game :game.', ['game' => $request->gamePref ]));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class ProfileController extends Controller
|
||||||
'roles' => $roleList,
|
'roles' => $roleList,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
abort(403, 'You cannot view someone else\'s profile.');
|
abort(403, __('You cannot view someone else\'s profile.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class ProfileController extends Controller
|
||||||
|
|
||||||
$newProfile = $profile->save();
|
$newProfile = $profile->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Profile settings saved successfully.');
|
$request->session()->flash('success', __('Profile settings saved successfully.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
class ResponseController extends Controller
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -41,7 +41,7 @@ class SecuritySettingsController extends Controller
|
||||||
Options::changeOption('force2fa', $request->enforce2fa);
|
Options::changeOption('force2fa', $request->enforce2fa);
|
||||||
Options::changeOption('requireGameLicense', $request->requirePMC);
|
Options::changeOption('requireGameLicense', $request->requirePMC);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Settings saved successfully.');
|
$request->session()->flash('success', __('Settings saved successfully.'));
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright © 2020 Miguel Nogueira
|
|
||||||
*
|
|
||||||
* This file is part of Raspberry Staff Manager.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
|
||||||
|
|
||||||
class StaffProfileController extends Controller
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -70,7 +70,7 @@ class TeamController extends Controller
|
||||||
|
|
||||||
Auth::user()->teams()->attach($team->id);
|
Auth::user()->teams()->attach($team->id);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Team successfully created.');
|
$request->session()->flash('success', __('Team successfully created.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -110,8 +110,7 @@ class TeamController extends Controller
|
||||||
$team->openJoin = $request->joinType;
|
$team->openJoin = $request->joinType;
|
||||||
|
|
||||||
$team->save();
|
$team->save();
|
||||||
|
$request->session()->flash('success', __('Team edited successfully.'));
|
||||||
$request->session()->flash('success', 'Team edited successfully.');
|
|
||||||
|
|
||||||
return redirect()->to(route('teams.index'));
|
return redirect()->to(route('teams.index'));
|
||||||
}
|
}
|
||||||
|
@ -139,12 +138,12 @@ class TeamController extends Controller
|
||||||
Mail::to($user)->send(new InviteToTeam($invite));
|
Mail::to($user)->send(new InviteToTeam($invite));
|
||||||
});
|
});
|
||||||
|
|
||||||
$request->session()->flash('success', 'Invite sent! They can now accept or deny it.');
|
$request->session()->flash('success', __('Invite sent! They can now accept or deny it.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'This user has already been invited.');
|
$request->session()->flash('error', __('This user has already been invited.'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'You can\'t invite users to public teams.');
|
$request->session()->flash('error', __('You can\'t invite users to public teams.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -159,9 +158,9 @@ class TeamController extends Controller
|
||||||
|
|
||||||
if ($invite && $invite->user->is(Auth::user())) {
|
if ($invite && $invite->user->is(Auth::user())) {
|
||||||
Teamwork::acceptInvite($invite);
|
Teamwork::acceptInvite($invite);
|
||||||
$request->session()->flash('success', 'Invite accepted! You have now joined '.$invite->team->name.'.');
|
$request->session()->flash('success', __('Invite accepted! You have now joined :teamName.', ['teamName' => $invite->team->name]));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Invalid or expired invite URL.');
|
$request->session()->flash('error', __('Invalid or expired invite URL.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -172,9 +171,9 @@ class TeamController extends Controller
|
||||||
|
|
||||||
if ($invite && $invite->user->is(Auth::user())) {
|
if ($invite && $invite->user->is(Auth::user())) {
|
||||||
Teamwork::denyInvite($invite);
|
Teamwork::denyInvite($invite);
|
||||||
$request->session()->flash('success', 'Invite denied! Ask for another invite if this isn\'t what you meant.');
|
$request->session()->flash('success', __('Invite denied! Ask for another invite if this isn\'t what you meant.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Invalid or expired invite URL.');
|
$request->session()->flash('error', __('Invalid or expired invite URL.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -195,9 +194,9 @@ class TeamController extends Controller
|
||||||
try {
|
try {
|
||||||
Auth::user()->switchTeam($team);
|
Auth::user()->switchTeam($team);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Switched teams! Your team dashboard will now use this context.');
|
$request->session()->flash('success', __('Switched teams! Your team dashboard will now use this context.'));
|
||||||
} catch (UserNotInTeamException $ex) {
|
} catch (UserNotInTeamException $ex) {
|
||||||
$request->session()->flash('error', 'You can\'t switch to a team you don\'t belong to.');
|
$request->session()->flash('error', __('You can\'t switch to a team you don\'t belong to.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -220,7 +219,7 @@ class TeamController extends Controller
|
||||||
$team->vacancies()->detach($vacancy->id);
|
$team->vacancies()->detach($vacancy->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', 'Removed all vacancy associations.');
|
$request->session()->flash('success', __('Removed all vacancy associations.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -240,7 +239,7 @@ class TeamController extends Controller
|
||||||
$team->vacancies()->attach($requestVacancies);
|
$team->vacancies()->attach($requestVacancies);
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', 'Assignments changed successfully.');
|
$request->session()->flash('success', __('Assignments changed successfully.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,11 @@ class TeamFileController extends Controller
|
||||||
Storage::delete($teamFile->fs_location);
|
Storage::delete($teamFile->fs_location);
|
||||||
$teamFile->delete();
|
$teamFile->delete();
|
||||||
|
|
||||||
$request->session()->flash('success', 'File deleted successfully.');
|
$request->session()->flash('success', __('File deleted successfully.'));
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
$request->session()->flash('error', 'There was an error deleting the file: ' . $ex->getMessage());
|
$request->session()->flash('error', __('There was an error deleting the file: :msg', ['msg' => $ex->getMessage()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
|
@ -204,9 +204,9 @@ class UserController extends Controller
|
||||||
]);
|
]);
|
||||||
$user->notify(new EmailChanged());
|
$user->notify(new EmailChanged());
|
||||||
|
|
||||||
$request->session()->flash('success', 'Your email address has been changed!');
|
$request->session()->flash('success', __('Your email address has been changed!'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'There has been an error whilst trying to update your account. Please contact administrators.');
|
$request->session()->flash('error', __('There has been an error whilst trying to update your account. Please contact administrators.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -218,9 +218,9 @@ class UserController extends Controller
|
||||||
|
|
||||||
if ($request->confirmPrompt == 'DELETE ACCOUNT') {
|
if ($request->confirmPrompt == 'DELETE ACCOUNT') {
|
||||||
$user->forceDelete();
|
$user->forceDelete();
|
||||||
$request->session()->flash('success', 'User deleted successfully. PII has been erased.');
|
$request->session()->flash('success', __('User deleted successfully.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Wrong confirmation text! Try again.');
|
$request->session()->flash('error', __('Wrong confirmation text! Try again.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('registeredPlayerList');
|
return redirect()->route('registeredPlayerList');
|
||||||
|
@ -287,9 +287,9 @@ class UserController extends Controller
|
||||||
$request->session()->forget('twofaAttemptFailed');
|
$request->session()->forget('twofaAttemptFailed');
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash('success', '2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.');
|
$request->session()->flash('success', __('2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.'));
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.');
|
$request->session()->flash('error', __('Incorrect code. Please reopen the 2FA settings panel and try again.'));
|
||||||
$request->session()->put('twofaAttemptFailed', true);
|
$request->session()->put('twofaAttemptFailed', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ class UserController extends Controller
|
||||||
$request->user()->twofa_secret = null;
|
$request->user()->twofa_secret = null;
|
||||||
$request->user()->save();
|
$request->user()->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Two-factor authentication disabled.');
|
$request->session()->flash('success', __('Two-factor authentication disabled.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ class UserController extends Controller
|
||||||
|
|
||||||
// TODO: move logic to policy
|
// TODO: move logic to policy
|
||||||
if (! $user->isStaffMember() || $user->is(Auth::user())) {
|
if (! $user->isStaffMember() || $user->is(Auth::user())) {
|
||||||
$request->session()->flash('error', 'You cannot terminate this user.');
|
$request->session()->flash('error', __('You cannot terminate this user.'));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ class UserController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('User '.$user->name.' has just been demoted.');
|
Log::info('User '.$user->name.' has just been demoted.');
|
||||||
$request->session()->flash('success', 'User terminated successfully.');
|
$request->session()->flash('success', __('User terminated successfully.'));
|
||||||
|
|
||||||
//TODO: Dispatch event
|
//TODO: Dispatch event
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\JSON;
|
||||||
use App\Form;
|
use App\Form;
|
||||||
use App\Http\Requests\VacancyEditRequest;
|
use App\Http\Requests\VacancyEditRequest;
|
||||||
use App\Http\Requests\VacancyRequest;
|
use App\Http\Requests\VacancyRequest;
|
||||||
|
@ -45,7 +46,11 @@ class VacancyController extends Controller
|
||||||
|
|
||||||
public function store(VacancyRequest $request)
|
public function store(VacancyRequest $request)
|
||||||
{
|
{
|
||||||
|
$messageIsError = false;
|
||||||
$this->authorize('create', Vacancy::class);
|
$this->authorize('create', Vacancy::class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$form = Form::find($request->vacancyFormID);
|
$form = Form::find($request->vacancyFormID);
|
||||||
|
|
||||||
if (! is_null($form)) {
|
if (! is_null($form)) {
|
||||||
|
@ -67,12 +72,16 @@ class VacancyController extends Controller
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.');
|
$message = __('Vacancy successfully opened. It will now show in the home page.');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$request->session()->flash('error', 'You cannot create a vacancy without a valid form.');
|
$message = __('You cannot create a vacancy without a valid form.');
|
||||||
|
$messageIsError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with(($messageIsError) ? 'error' : 'success', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
|
public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy)
|
||||||
|
@ -85,13 +94,13 @@ class VacancyController extends Controller
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 'open':
|
case 'open':
|
||||||
$vacancy->open();
|
$vacancy->open();
|
||||||
$message = 'Position successfully opened!';
|
$message = __('Position successfully opened!');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'close':
|
case 'close':
|
||||||
$vacancy->close();
|
$vacancy->close();
|
||||||
$message = 'Position successfully closed!';
|
$message = __('Position successfully closed!');
|
||||||
|
|
||||||
foreach (User::all() as $user) {
|
foreach (User::all() as $user) {
|
||||||
if ($user->isStaffMember()) {
|
if ($user->isStaffMember()) {
|
||||||
|
@ -101,18 +110,19 @@ class VacancyController extends Controller
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$message = "Please do not tamper with the button's URLs. To report a bug, please contact an administrator.";
|
$message = __("Please do not tamper with the URLs. To report a bug, please contact an administrator.");
|
||||||
$type = 'error';
|
$type = 'error';
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = "The position you're trying to update doesn't exist!";
|
$message = __("The position you're trying to update doesn't exist!");
|
||||||
$type = 'error';
|
$type = 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->session()->flash($type, $message);
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with($type, $message);
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Request $request, Vacancy $vacancy)
|
public function edit(Request $request, Vacancy $vacancy)
|
||||||
|
@ -133,8 +143,8 @@ class VacancyController extends Controller
|
||||||
|
|
||||||
$vacancy->save();
|
$vacancy->save();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Vacancy successfully updated.');
|
return redirect()
|
||||||
|
->back()
|
||||||
return redirect()->back();
|
->with('success', __('Vacancy successfully updated.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ trait ReceivesAccountTokens
|
||||||
$user->delete();
|
$user->delete();
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Please check your email to finish deleting your account.');
|
$request->session()->flash('success', __('Please check your email to finish deleting your account.'));
|
||||||
|
|
||||||
return redirect()->to('/');
|
return redirect()->to('/');
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ trait ReceivesAccountTokens
|
||||||
|
|
||||||
$user->forceDelete();
|
$user->forceDelete();
|
||||||
|
|
||||||
$request->session()->flash('success', 'Account permanently deleted. Thank you for using our service.');
|
$request->session()->flash('success', __('Account permanently deleted. Thank you for using our service.'));
|
||||||
|
|
||||||
return redirect()->to('/');
|
return redirect()->to('/');
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ trait ReceivesAccountTokens
|
||||||
|
|
||||||
if ($user->verifyAccountToken($token, 'cancelToken')) {
|
if ($user->verifyAccountToken($token, 'cancelToken')) {
|
||||||
$user->restore();
|
$user->restore();
|
||||||
$request->session()->flash('success', 'Account deletion cancelled! You may now login.');
|
$request->session()->flash('success', __('Account deletion cancelled! You may now login.'));
|
||||||
|
|
||||||
return redirect()->to(route('login'));
|
return redirect()->to(route('login'));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ trait ReceivesAccountTokens
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
abort(404, 'The page you were trying to access may not exist or may be expired.');
|
abort(404, __('The page you were trying to access may not exist or may be expired.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,8 @@ Route::middleware(['api'])->group(function (){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'vacancies'], function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue