Add save & update functionality to positions
Tooltips also added, as well as a general configuration file for Mojang Status URL. Relationships were also added between forms and Vacancies. Status verification for the dashboard was moved to a Service Provider, where it adds log entries when cache expires. Authentication controllers were also updated to reflect the new dashboard URL.
This commit is contained in:
@@ -26,7 +26,7 @@ class ConfirmPasswordController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
@@ -26,5 +26,5 @@ class ResetPasswordController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/dashboard';
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ class VerificationController extends Controller
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
@@ -5,23 +5,14 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
// TODO: Switch status checking to provider, share with all views
|
||||
|
||||
// Mojang status for informational purposes
|
||||
if (!Cache::has('mojang_status'))
|
||||
{
|
||||
$mcstatus = Http::get('https://status.mojang.com/check');
|
||||
Cache::put('mojang_status', base64_encode($mcstatus->body()), now()->addMinutes(60));
|
||||
}
|
||||
|
||||
return view('dashboard.dashboard')
|
||||
->with('mcstatus', json_decode(base64_decode(Cache::get('mojang_status')), true));
|
||||
return view('dashboard.dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,14 +2,86 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Form;
|
||||
use App\Http\Requests\VacancyRequest;
|
||||
use App\Vacancy;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class VacancyController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('dashboard.administration.positions');
|
||||
return view('dashboard.administration.positions')
|
||||
->with([
|
||||
'forms' => Form::all(),
|
||||
'vacancies' => Vacancy::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(VacancyRequest $request)
|
||||
{
|
||||
$form = Form::find($request->vacancyFormID);
|
||||
|
||||
if (!is_null($form))
|
||||
{
|
||||
Vacancy::create([
|
||||
|
||||
'vacancyName' => $request->vacancyName,
|
||||
'vacancyDescription' => $request->vacancyDescription,
|
||||
'permissionGroupName' => $request->permissionGroup,
|
||||
'discordRoleID' => $request->discordRole,
|
||||
'vacancyFormID' => $request->vacancyFormID,
|
||||
'vacancyCount' => $request->vacancyCount
|
||||
|
||||
]);
|
||||
|
||||
$request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$request->session()->flash('error', 'You cannot create a vacancy without a valid form.');
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
public function updatePositionAvailability(Request $request, $status, $id)
|
||||
{
|
||||
$vacancy = Vacancy::find($id);
|
||||
|
||||
if (!is_null($vacancy))
|
||||
{
|
||||
$type = 'success';
|
||||
|
||||
switch ($status)
|
||||
{
|
||||
case 'open':
|
||||
$vacancy->open();
|
||||
$message = "Position successfully opened!";
|
||||
|
||||
break;
|
||||
|
||||
case 'close':
|
||||
$vacancy->close();
|
||||
$message = "Position successfully closed!";
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$message = "Please do not tamper with the button's URLs. To report a bug, please contact an administrator.";
|
||||
$type = 'error';
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = "The position you're trying to update doesn't exist!";
|
||||
$type = "error";
|
||||
}
|
||||
|
||||
$request->session()->flash($type, $message);
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
}
|
||||
|
35
app/Http/Requests/VacancyRequest.php
Normal file
35
app/Http/Requests/VacancyRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class VacancyRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'vacancyName' => 'required|string',
|
||||
'vacancyDescription' => 'required|string',
|
||||
'permissionGroup' => 'required|string',
|
||||
'discordRole' => 'required|string',
|
||||
'vacancyCount' => 'required|integer',
|
||||
'vacancyFormID' => 'required|integer'
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user