File "IntegrationController-20260128172012.php"
Full Path: /var/www/html/back/app/Http/Controllers/Api/V1/IntegrationController-20260128172012.php
File size: 1.34 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Api\ApiController;
use App\Models\Integration;
use App\Services\IntegrationService;
use Illuminate\Http\Request;
use Laravel\Sanctum\PersonalAccessToken;
class IntegrationController extends ApiController
{
public function __construct(protected IntegrationService $integrationService)
{
}
public function index()
{
return $this->integrationService->index();
}
public function show($integrationId)
{
return Integration::query()->find($integrationId);
}
public function store($modelId, Request $request)
{
return $this->integrationService->store($modelId, $request->toArray());
}
public function update($integrationId, Request $request)
{
return $this->integrationService->update($integrationId, $request->toArray());
}
public function getToken(Request $request)
{
$token = $request->bearerToken()
?? $request->header('X-Integration-Token')
?? $request->query('token');
$access = PersonalAccessToken::findToken($token);
return $access->tokenable_id;
}
public function addData(Request $request)
{
$modelId = $this->getToken($request);
return $this->integrationService->addData($modelId, $request->toArray());
}
}