Você não pode selecionar mais de 25 tópicos
Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
|
- <?php
-
- namespace App\Http\Controllers\Web\LoginUser;
-
- use App\Codes\UserRole;
- use App\Exceptions\AppCommonException;
- use App\Features\LoginUser;
- use App\Http\Controllers\Web\IParam;
- use App\Http\Controllers\Web\WebController;
- use App\Logic\User\LoginUserManager;
- use App\Repositories\LoginUserRepository;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Http\Request;
-
- class CreateController extends WebController
- {
-
- use LoginUser;
-
- public function name(): string
- {
- return "ログインユーザー一覧取得";
- }
-
- public function description(): string
- {
- return "ログインユーザー一覧を取得する";
- }
-
- public function __construct(
- protected CreateParam $param,
- private LoginUserManager $manager
- ) {
- parent::__construct();
- $this->roleAllow(UserRole::CONTRACT_ADMIN);
- }
-
- protected function getParam(): IParam
- {
- return $this->param;
- }
-
- protected function run(Request $request): JsonResponse
- {
- $param = $this->param;
-
-
- try {
- $this->transaction->beginTransaction();
-
-
- $currentContract = $this->loginUser()->getCurrentContract();
- if (!$currentContract) {
- throw new AppCommonException("認証不正");
- }
-
- $messages = $this->manager->initForCreate($currentContract)
- ->fill($param->toArray())
- ->create();
-
- if (count($messages) !== 0) {
- $this->transaction->rollBack();
- return $this->validateErrorResponse($messages);
- }
-
- $this->transaction->commit();
- } catch (Exception $e) {
- $this->transaction->rollBack();
- throw $e;
- }
-
- return $this->successResponse();
- }
- }
|