Otherwise phpstorm doesn't understand the paths correctly. He thinks that this is not a complete application, but a package. And when creating a class, the namespace indicates “app” with a small letter, but should be “App”.
26 lines
774 B
PHP
26 lines
774 B
PHP
<?php declare(strict_types = 1);
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Requests\Admin\Languages\NewLanguageRequest;
|
|
use App\Http\Resources\Admin\Languages\NewLanguage;
|
|
use App\Services\Admin\LanguageService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
final class LanguagesController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly LanguageService $languageService,
|
|
) { }
|
|
|
|
public function newLanguage(NewLanguageRequest $request): JsonResponse
|
|
{
|
|
$result = $this->languageService->newLanguage($request->getDto());
|
|
if ($result->isError()) {
|
|
return response()->json($result->getData())->setStatusCode($result->getCode());
|
|
}
|
|
|
|
return response()->json(new NewLanguage($result));
|
|
}
|
|
}
|