mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-09-30 06:13:09 -04:00
106 lines
2.6 KiB
PHP
106 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\WTIJobBoard\Http\Controllers;
|
|
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\WTIJobBoard\Http\Requests\JobRequestApplication;
|
|
use Modules\WTIJobBoard\Http\Requests\UpdateJobRequestApplication;
|
|
use Modules\WTIJobBoard\Services\JobRequestApplicationsService;
|
|
|
|
class JobRequestApplicationsController extends Controller
|
|
{
|
|
protected $service;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->service = new JobRequestApplicationsService();
|
|
}
|
|
|
|
public function store(JobRequestApplication $request)
|
|
{
|
|
|
|
$this->service->store($request->except('_token'));
|
|
|
|
return response()->json([
|
|
'message' => 'Application has been posted.'
|
|
]);
|
|
}
|
|
|
|
public function update(UpdateJobRequestApplication $request)
|
|
{
|
|
|
|
$this->service->update($request->except('_token'));
|
|
|
|
return response()->json([
|
|
'message' => 'Application has been updated.'
|
|
]);
|
|
}
|
|
|
|
public function cancel(Request $request)
|
|
{
|
|
|
|
$ret = $this->service->cancel($request->id);
|
|
|
|
if ($ret) {
|
|
return response()->json([
|
|
'message' => 'Application has been cancelled.'
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Failed to cancel the applicant.'
|
|
], 400);
|
|
|
|
}
|
|
|
|
public function hire(Request $request)
|
|
{
|
|
|
|
if (permissionCheck('job_request.application.hire')) {
|
|
|
|
$ret = $this->service->hire($request->id);
|
|
|
|
if ($ret) {
|
|
$creator = $ret->creator;
|
|
$name = "{$creator->first_name} {$creator->last_name}";
|
|
|
|
return response()->json([
|
|
'message' => "{$name} has been hired."
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Failed to hire the applicant.'
|
|
], 400);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => "You don't have permission to perform this action."
|
|
], 403);
|
|
}
|
|
|
|
public function terminate(Request $request)
|
|
{
|
|
|
|
$ret = $this->service->terminate($request->id);
|
|
|
|
if ($ret) {
|
|
return response()->json([
|
|
'message' => 'Terminated successfully.'
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Failed to terminate.'
|
|
], 400);
|
|
|
|
}
|
|
|
|
public function all(Request $request)
|
|
{
|
|
return response()->json($this->service->creator($request->id));
|
|
}
|
|
}
|