You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 line
1.5KB

  1. <?php
  2. namespace App\Http\Controllers\Web\SeasonTicketContract;
  3. use App\Http\Controllers\Web\WebController;
  4. use App\Kintone\Models\SeasonTicketContract;
  5. use App\Util\DateUtil;
  6. use Illuminate\Http\JsonResponse;
  7. use Illuminate\Http\Request;
  8. class UploadOtherLicenseImagesController extends WebController
  9. {
  10. public function name(): string
  11. {
  12. return "その他証明証画像アップロード";
  13. }
  14. public function description(): string
  15. {
  16. return "その他証明証画像をアップロードする";
  17. }
  18. public function __construct(protected UploadStudentLicenseImagesParam $param)
  19. {
  20. parent::__construct();
  21. $this->middleware('auth:sanctum');
  22. }
  23. protected function run(Request $request): JsonResponse
  24. {
  25. $param = $this->param;
  26. $access = SeasonTicketContract::getAccess();
  27. $seasonTicketContract = $access->find($param->seasonTicketContractRecordNo);
  28. $data = [];
  29. foreach ($param->images as $index => $file) {
  30. $data[] = [
  31. 'fileKey' => $access->filePut($file),
  32. 'name' => sprintf("image_%d.%s", $index, $file->extension()),
  33. 'contentType' => $file->getClientMimeType(),
  34. ];
  35. }
  36. $seasonTicketContract->set(SeasonTicketContract::FIELD_OTHER_LICENSE_IMAGES, $data);
  37. $seasonTicketContract->set(SeasonTicketContract::FIELD_OTHER_LICENSE_IMAGES_UPLOAD_DATETIME, DateUtil::now());
  38. $access->update($seasonTicketContract);
  39. return $this->successResponse();
  40. }
  41. }