2020-04-29 17:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2020-05-07 23:24:56 +00:00
|
|
|
use App\Form;
|
|
|
|
use App\Http\Requests\VacancyRequest;
|
|
|
|
use App\Vacancy;
|
2020-04-29 17:15:54 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class VacancyController extends Controller
|
|
|
|
{
|
2020-05-03 04:04:26 +00:00
|
|
|
public function index()
|
|
|
|
{
|
2020-05-07 23:24:56 +00:00
|
|
|
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();
|
2020-05-03 04:04:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 17:15:54 +00:00
|
|
|
}
|