fix positions
This commit is contained in:
@@ -235,7 +235,7 @@ class JobPostingController extends BaseController
|
||||
public function positions()
|
||||
{
|
||||
return view('jobs/admin/positions', [
|
||||
'positions' => $this->positions->openPositions(),
|
||||
'positions' => $this->positions->adminPositions(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -263,6 +263,9 @@ class JobPostingController extends BaseController
|
||||
|
||||
$payload['position_id'] = $this->newUuid();
|
||||
$payload['posted_by'] = $this->currentUserId();
|
||||
if ($payload['status'] === 'open') {
|
||||
$payload['posted_at'] = utc_now();
|
||||
}
|
||||
|
||||
if (!$this->positions->insert($payload)) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unable to create position.');
|
||||
@@ -287,11 +290,20 @@ class JobPostingController extends BaseController
|
||||
|
||||
public function updatePosition(string $positionId)
|
||||
{
|
||||
$position = $this->positions->find($positionId);
|
||||
if (!$position) {
|
||||
return redirect()->to(site_url(self::ADMIN_FILTER_ROUTE . '/positions'))->with('error', 'Position not found.');
|
||||
}
|
||||
|
||||
$payload = $this->positionPayload();
|
||||
if ($payload === null) {
|
||||
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
if ($payload['status'] === 'open' && (($position['status'] ?? '') !== 'open' || empty($position['posted_at']))) {
|
||||
$payload['posted_at'] = utc_now();
|
||||
}
|
||||
|
||||
if (!$this->positions->update($positionId, $payload)) {
|
||||
return redirect()->back()->withInput()->with('error', 'Unable to update position.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user