領収証発行サービス
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

64 lines
1.5KB

  1. <?php
  2. namespace App\Http\Controllers\Web\LoginUser;
  3. use App\Codes\UserRole;
  4. use App\Exceptions\AppCommonException;
  5. use App\Features\LoginUser;
  6. use App\Http\Controllers\Web\IParam;
  7. use App\Http\Controllers\Web\WebController;
  8. use App\Repositories\LoginUserRepository;
  9. use Illuminate\Http\JsonResponse;
  10. use Illuminate\Http\Request;
  11. class LoginUsersController extends WebController
  12. {
  13. use LoginUser;
  14. public function name(): string
  15. {
  16. return "ログインユーザー一覧取得";
  17. }
  18. public function description(): string
  19. {
  20. return "ログインユーザー一覧を取得する";
  21. }
  22. public function __construct(
  23. protected LoginUsersParam $param,
  24. private LoginUserRepository $repository
  25. ) {
  26. parent::__construct();
  27. $this->roleAllow(UserRole::CONTRACT_ADMIN);
  28. }
  29. protected function getParam(): IParam
  30. {
  31. return $this->param;
  32. }
  33. protected function run(Request $request): JsonResponse
  34. {
  35. $param = $this->param;
  36. $currentContractId = $this->loginUser()->getCurrentContractId();
  37. if (!$currentContractId) {
  38. throw new AppCommonException("認証不正");
  39. }
  40. $condition = [
  41. ...$param->toArray(),
  42. LoginUserRepository::CONDITION_CONTRACT_ID => $currentContractId,
  43. ];
  44. $list = $this->repository->get($condition);
  45. return $this->successResponse([
  46. 'records' => $list
  47. ]);
  48. }
  49. }