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.

36 line
777B

  1. <?php
  2. namespace App\Logics\Shop;
  3. use App\Exceptions\ParamException;
  4. use App\Models\HtpmsCustomer\Deposit\Deposit;
  5. use App\Models\HtpmsCustomer\Mst\Shop;
  6. use App\Models\User;
  7. class ShopLogic
  8. {
  9. private User|null $customerUser = null;
  10. private Shop|null $shop = null;
  11. public function create(User $customerUser, Shop $shop)
  12. {
  13. $this->customerUser = $customerUser;
  14. $this->shop = $shop;
  15. // チェック処理
  16. if (Shop::whereName($shop->name)->exists()) {
  17. ParamException::throw(Shop::COL_NAME_NAME, trans('validation.unique'));
  18. }
  19. $shop->save();
  20. // デポジット
  21. $deposit = new Deposit();
  22. $deposit->shop_id = $shop->id;
  23. $deposit->save();
  24. return $shop;
  25. }
  26. }