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.

53 line
1.1KB

  1. <?php
  2. namespace App\Http\Controllers\Web\Shop;
  3. use App\Http\Controllers\Web\WebController;
  4. use App\Logics\LoginUser\LoginUserLogic;
  5. use App\Logics\Shop\ShopLogic;
  6. use App\Models\HtpmsCustomer\Mst\Shop;
  7. use App\Models\User;
  8. use Illuminate\Http\JsonResponse;
  9. use Illuminate\Http\Request;
  10. use LogicException;
  11. class ShopRegisterController extends WebController
  12. {
  13. public function name(): string
  14. {
  15. return "店舗マスタ新規登録";
  16. }
  17. public function description(): string
  18. {
  19. return "店舗マスタを新規登録する";
  20. }
  21. public function __construct(protected ShopRegisterParam $param, protected ShopLogic $logic)
  22. {
  23. parent::__construct();
  24. }
  25. protected function run(Request $request): JsonResponse
  26. {
  27. $param = $this->param;
  28. $user = $this->sessionUser->user();
  29. if ($user === null) {
  30. throw new LogicException();
  31. }
  32. $shop = new Shop();
  33. $shop->fill($param->toArray());
  34. $this->logic->create($user, $shop);
  35. $res = [
  36. "shop_id" => $shop->id,
  37. ];
  38. return $this->successResponse($res);
  39. }
  40. }