Miguel Nogueira
4c6a435e34
This commit finally adds the dynamically rendered form that changes according to how the user builds their form. It also fragments the header and footer for the main page into their own separate files for ease of access later. Vacancy status has also been added to the Vacancies in DB. All staff application endpoints have also been moved to under the user application endpoints group, for ease of use (duplicated route group).
90 lines
2.3 KiB
PHP
90 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Form;
|
|
use App\Http\Requests\VacancyRequest;
|
|
use App\Vacancy;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Str;
|
|
|
|
class VacancyController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
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,
|
|
'vacancySlug' => Str::slug($request->vacancyName),
|
|
'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();
|
|
}
|
|
|
|
}
|