51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Agent;
|
|
use App\Models\IntegrationRequest;
|
|
use App\Models\IntegrationTemplate;
|
|
use App\Services\IntegrationService;
|
|
use App\Enums\IntegrationStatus;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
|
|
class OffboardingController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
return Inertia::render('Offboarding/Index', [
|
|
'active_agents' => Agent::where('integration_status', IntegrationStatus::Completed)->get(),
|
|
'current_offboardings' => IntegrationRequest::where('type', 'offboarding')
|
|
->with(['agent', 'template'])
|
|
->get(),
|
|
]);
|
|
}
|
|
|
|
public function create(Agent $agent)
|
|
{
|
|
return Inertia::render('Offboarding/Create', [
|
|
'agent' => $agent,
|
|
'templates' => IntegrationTemplate::where('is_active', true)->get(),
|
|
]);
|
|
}
|
|
|
|
public function store(Request $request, IntegrationService $service)
|
|
{
|
|
$validated = $request->validate([
|
|
'agent_id' => 'required|exists:agents,id',
|
|
'template_id' => 'nullable|exists:integration_templates,id',
|
|
'departure_date' => 'required|date',
|
|
]);
|
|
|
|
$integration = $service->createProcess([
|
|
'agent_id' => $validated['agent_id'],
|
|
'template_id' => $validated['template_id'],
|
|
'type' => 'offboarding',
|
|
'departure_date' => $validated['departure_date'],
|
|
]);
|
|
|
|
return redirect()->route('integrations.show', $integration);
|
|
}
|
|
}
|