From f1d3271c904dd83769ffcbcb3fcff7b45f40d3a6 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Mon, 25 Mar 2024 10:16:47 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=84=E3=82=8D=E3=81=84=E3=82=8D=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Exceptions/ParamException.php | 17 ++ .../Web/Customer/CustomerListController.php | 39 ++++ .../Web/Customer/CustomerListParam.php | 9 + .../Web/LoginUser/CustomerListController.php | 43 ++++ .../Web/LoginUser/CustomerListParam.php | 23 ++ .../LoginUser/CustomerRegisterController.php | 45 ++++ .../Web/LoginUser/CustomerRegisterParam.php | 27 +++ .../Web/LoginUser/ShopRegisterController.php | 50 +++++ .../Web/LoginUser/ShopRegisterParam.php | 27 +++ .../Web/Shop/DepositChargeController.php | 53 +++++ .../Web/Shop/DepositChargeParam.php | 21 ++ .../Web/Shop/MyDepositController.php | 43 ++++ .../Controllers/Web/Shop/MyDepositParam.php | 9 + .../Web/Shop/ShopListController.php | 41 ++++ .../Controllers/Web/Shop/ShopListParam.php | 9 + .../Web/Shop/ShopRegisterController.php | 52 +++++ .../Web/Shop/ShopRegisterParam.php | 19 ++ app/Http/Controllers/Web/WebController.php | 4 + app/Logics/LoginUser/LoginUserLogic.php | 62 ++++++ app/Logics/QRService/ChargeLogic.php | 27 +++ app/Logics/Shop/ShopLogic.php | 32 +++ app/Models/Htpms/MstCustomer.php | 5 + app/Models/User.php | 3 +- app/Providers/RouteServiceProvider.php | 7 +- app/Repositories/BaseRepository.php | 81 +++++++ app/Repositories/BaseRepositoryData.php | 34 +++ app/Repositories/LoginUserRepository.php | 90 ++++++++ app/Repositories/LoginUserRepositoryData.php | 13 ++ app/Repositories/ShopRepository.php | 78 +++++++ app/Repositories/ShopRepositoryData.php | 13 ++ app/Sessions/SessionUser.php | 14 ++ lang/en/auth.php | 20 ++ lang/en/pagination.php | 19 ++ lang/en/passwords.php | 22 ++ lang/en/validation.php | 184 ++++++++++++++++ lang/ja/auth.php | 20 ++ lang/ja/pagination.php | 19 ++ lang/ja/passwords.php | 22 ++ lang/ja/validation.php | 205 ++++++++++++++++++ routes/api.php | 19 ++ 40 files changed, 1514 insertions(+), 6 deletions(-) create mode 100644 app/Exceptions/ParamException.php create mode 100644 app/Http/Controllers/Web/Customer/CustomerListController.php create mode 100644 app/Http/Controllers/Web/Customer/CustomerListParam.php create mode 100644 app/Http/Controllers/Web/LoginUser/CustomerListController.php create mode 100644 app/Http/Controllers/Web/LoginUser/CustomerListParam.php create mode 100644 app/Http/Controllers/Web/LoginUser/CustomerRegisterController.php create mode 100644 app/Http/Controllers/Web/LoginUser/CustomerRegisterParam.php create mode 100644 app/Http/Controllers/Web/LoginUser/ShopRegisterController.php create mode 100644 app/Http/Controllers/Web/LoginUser/ShopRegisterParam.php create mode 100644 app/Http/Controllers/Web/Shop/DepositChargeController.php create mode 100644 app/Http/Controllers/Web/Shop/DepositChargeParam.php create mode 100644 app/Http/Controllers/Web/Shop/MyDepositController.php create mode 100644 app/Http/Controllers/Web/Shop/MyDepositParam.php create mode 100644 app/Http/Controllers/Web/Shop/ShopListController.php create mode 100644 app/Http/Controllers/Web/Shop/ShopListParam.php create mode 100644 app/Http/Controllers/Web/Shop/ShopRegisterController.php create mode 100644 app/Http/Controllers/Web/Shop/ShopRegisterParam.php create mode 100644 app/Logics/LoginUser/LoginUserLogic.php create mode 100644 app/Logics/QRService/ChargeLogic.php create mode 100644 app/Logics/Shop/ShopLogic.php create mode 100644 app/Repositories/BaseRepository.php create mode 100644 app/Repositories/BaseRepositoryData.php create mode 100644 app/Repositories/LoginUserRepository.php create mode 100644 app/Repositories/LoginUserRepositoryData.php create mode 100644 app/Repositories/ShopRepository.php create mode 100644 app/Repositories/ShopRepositoryData.php create mode 100644 lang/en/auth.php create mode 100644 lang/en/pagination.php create mode 100644 lang/en/passwords.php create mode 100644 lang/en/validation.php create mode 100644 lang/ja/auth.php create mode 100644 lang/ja/pagination.php create mode 100644 lang/ja/passwords.php create mode 100644 lang/ja/validation.php diff --git a/app/Exceptions/ParamException.php b/app/Exceptions/ParamException.php new file mode 100644 index 0000000..03362e0 --- /dev/null +++ b/app/Exceptions/ParamException.php @@ -0,0 +1,17 @@ +target = $target; + throw $exception; + } +} diff --git a/app/Http/Controllers/Web/Customer/CustomerListController.php b/app/Http/Controllers/Web/Customer/CustomerListController.php new file mode 100644 index 0000000..5102a6f --- /dev/null +++ b/app/Http/Controllers/Web/Customer/CustomerListController.php @@ -0,0 +1,39 @@ + $list->toArray(), + ]; + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/Customer/CustomerListParam.php b/app/Http/Controllers/Web/Customer/CustomerListParam.php new file mode 100644 index 0000000..a363034 --- /dev/null +++ b/app/Http/Controllers/Web/Customer/CustomerListParam.php @@ -0,0 +1,9 @@ +param; + + $list = $this->repository->get([ + ...$param->toArray(), + LoginUserRepository::CONDITION_ROLE => UserRole::CUSTOMER->value, + ]); + $res = [ + "list" => $list, + ]; + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/LoginUser/CustomerListParam.php b/app/Http/Controllers/Web/LoginUser/CustomerListParam.php new file mode 100644 index 0000000..1cb9010 --- /dev/null +++ b/app/Http/Controllers/Web/LoginUser/CustomerListParam.php @@ -0,0 +1,23 @@ + $this->str(true), + LoginUserRepository::CONDITION_NAME => $this->str(true), + ...$this->sortableRules(), + ]; + } +} diff --git a/app/Http/Controllers/Web/LoginUser/CustomerRegisterController.php b/app/Http/Controllers/Web/LoginUser/CustomerRegisterController.php new file mode 100644 index 0000000..2a196ce --- /dev/null +++ b/app/Http/Controllers/Web/LoginUser/CustomerRegisterController.php @@ -0,0 +1,45 @@ +param; + $user = new User(); + $user->fill($param->toArray()); + $user->password = $param->password; + + $this->logic->createCustomerUser($user); + + $res = [ + "user_id" => $user->id, + ]; + + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/LoginUser/CustomerRegisterParam.php b/app/Http/Controllers/Web/LoginUser/CustomerRegisterParam.php new file mode 100644 index 0000000..1bf9c6f --- /dev/null +++ b/app/Http/Controllers/Web/LoginUser/CustomerRegisterParam.php @@ -0,0 +1,27 @@ + $this->str(), + User::COL_NAME_EMAIL => $this->str([...Rule::email()]), + User::COL_NAME_PASSWORD => $this->str([new LoginPassword()]), + User::COL_NAME_CUSTOMER_CODE => $this->str(), + ]; + } +} diff --git a/app/Http/Controllers/Web/LoginUser/ShopRegisterController.php b/app/Http/Controllers/Web/LoginUser/ShopRegisterController.php new file mode 100644 index 0000000..f78e856 --- /dev/null +++ b/app/Http/Controllers/Web/LoginUser/ShopRegisterController.php @@ -0,0 +1,50 @@ +sessionUser->customerCode(); + + $param = $this->param; + $user = new User(); + $user->fill($param->toArray()); + $user->password = $param->password; + $user->customer_code = $this->sessionUser->customerCode(); + + $shop = Shop::findOrFail($param->shopId); + $this->logic->createShopUser($shop, $user); + + $res = [ + "user_id" => $user->id, + ]; + + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/LoginUser/ShopRegisterParam.php b/app/Http/Controllers/Web/LoginUser/ShopRegisterParam.php new file mode 100644 index 0000000..d1c58bd --- /dev/null +++ b/app/Http/Controllers/Web/LoginUser/ShopRegisterParam.php @@ -0,0 +1,27 @@ + $this->str(), + User::COL_NAME_NAME => $this->str(), + User::COL_NAME_EMAIL => $this->str([...Rule::email()]), + User::COL_NAME_PASSWORD => $this->str([new LoginPassword()]), + ]; + } +} diff --git a/app/Http/Controllers/Web/Shop/DepositChargeController.php b/app/Http/Controllers/Web/Shop/DepositChargeController.php new file mode 100644 index 0000000..ff6a4ae --- /dev/null +++ b/app/Http/Controllers/Web/Shop/DepositChargeController.php @@ -0,0 +1,53 @@ +param; + + $user = $this->sessionUser->user(); + if ($user instanceof null) { + throw new LogicException(); + } + + if ($user->shop_id === null) { + throw new LogicException(); + } + + + $deposit = $this->logic->charge($user->shop_id, $param->amount); + + $res = [ + "shop_id" => $deposit->shop_id, + "deposit" => $deposit->deposit, + ]; + + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/Shop/DepositChargeParam.php b/app/Http/Controllers/Web/Shop/DepositChargeParam.php new file mode 100644 index 0000000..b2f3497 --- /dev/null +++ b/app/Http/Controllers/Web/Shop/DepositChargeParam.php @@ -0,0 +1,21 @@ + $this->str(), + Deposit::COL_NAME_DEPOSIT => $this->numeric(), + ]; + } +} diff --git a/app/Http/Controllers/Web/Shop/MyDepositController.php b/app/Http/Controllers/Web/Shop/MyDepositController.php new file mode 100644 index 0000000..cf4c46e --- /dev/null +++ b/app/Http/Controllers/Web/Shop/MyDepositController.php @@ -0,0 +1,43 @@ +sessionUser->user(); + if ($user === null) throw new LogicException(); + if ($user->shop_id === null) throw new LogicException(); + + $deposit = Deposit::whereShopId($user->shop_id) + ->firstOrFail(); + $res = [ + "deposit" => $deposit->deposit, + ]; + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/Shop/MyDepositParam.php b/app/Http/Controllers/Web/Shop/MyDepositParam.php new file mode 100644 index 0000000..9cc8f39 --- /dev/null +++ b/app/Http/Controllers/Web/Shop/MyDepositParam.php @@ -0,0 +1,9 @@ +repository->get([ + ...$this->param->toArray(), + ]); + + $res = [ + "list" => $list + ]; + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/Shop/ShopListParam.php b/app/Http/Controllers/Web/Shop/ShopListParam.php new file mode 100644 index 0000000..e855bd7 --- /dev/null +++ b/app/Http/Controllers/Web/Shop/ShopListParam.php @@ -0,0 +1,9 @@ +param; + $user = $this->sessionUser->user(); + if ($user === null) { + throw new LogicException(); + } + + $shop = new Shop(); + $shop->fill($param->toArray()); + + $this->logic->create($user, $shop); + + $res = [ + "shop_id" => $shop->id, + ]; + + return $this->successResponse($res); + } +} diff --git a/app/Http/Controllers/Web/Shop/ShopRegisterParam.php b/app/Http/Controllers/Web/Shop/ShopRegisterParam.php new file mode 100644 index 0000000..7db9269 --- /dev/null +++ b/app/Http/Controllers/Web/Shop/ShopRegisterParam.php @@ -0,0 +1,19 @@ + $this->str(), + ]; + } +} diff --git a/app/Http/Controllers/Web/WebController.php b/app/Http/Controllers/Web/WebController.php index 2ff7eeb..d4f7a9c 100644 --- a/app/Http/Controllers/Web/WebController.php +++ b/app/Http/Controllers/Web/WebController.php @@ -8,6 +8,7 @@ use App\Codes\UserRole; use App\Exceptions\AppCommonException; use App\Exceptions\ExclusiveException; use App\Exceptions\GeneralErrorMessageException; +use App\Exceptions\ParamException; use App\Sessions\SessionUser; use App\Util\DBUtil; use Exception; @@ -210,6 +211,9 @@ abstract class WebController extends BaseController return $this->unAuthorizedResponse(); } throw $e; + } catch (ParamException $e) { + $this->transaction->rollBack(); + throw $this->validateErrorResponse([$e->target => $e->getMessage()]); } catch (Exception $e) { $this->transaction->rollBack(); logs()->error([ diff --git a/app/Logics/LoginUser/LoginUserLogic.php b/app/Logics/LoginUser/LoginUserLogic.php new file mode 100644 index 0000000..c4c8706 --- /dev/null +++ b/app/Logics/LoginUser/LoginUserLogic.php @@ -0,0 +1,62 @@ +user = $user; + $user->role = UserRole::CUSTOMER; + + // チェック処理 + $this->checkEmailForCreate(); + $this->checkCustomerCode(); + + $user->save(); + } + + public function createShopUser(Shop $shop, User $user) + { + $this->user = $user; + $user->role = UserRole::SHOP; + $user->shop_id = $shop->id; + + // チェック処理 + $this->checkEmailForCreate(); + $this->checkCustomerCode(); + + $user->save(); + } + + + private function checkEmailForCreate() + { + if (User::whereEmail($this->user) + ->exists() + ) { + ParamException::throw(User::COL_NAME_EMAIL, trans('validation.unique')); + } + } + + private function checkCustomerCode() + { + $customer = MstCustomer::whereCustomerId($this->user->customer_code) + ->first(); + + if ($customer === null) { + ParamException::throw(User::COL_NAME_CUSTOMER_CODE, trans('validation.exists')); + return; + } + $this->user->customer_id = $customer->id; + } +} diff --git a/app/Logics/QRService/ChargeLogic.php b/app/Logics/QRService/ChargeLogic.php new file mode 100644 index 0000000..f4b9c61 --- /dev/null +++ b/app/Logics/QRService/ChargeLogic.php @@ -0,0 +1,27 @@ +deposit += $amount; + + self::makeTransferHistory($shopId, $amount); + + return $deposit; + } +} diff --git a/app/Logics/Shop/ShopLogic.php b/app/Logics/Shop/ShopLogic.php new file mode 100644 index 0000000..7f92823 --- /dev/null +++ b/app/Logics/Shop/ShopLogic.php @@ -0,0 +1,32 @@ +customerUser = $customerUser; + $this->shop = $shop; + + // チェック処理 + + + $shop->save(); + + // デポジット + $deposit = new Deposit(); + $deposit->shop_id = $shop->idl; + $deposit->save(); + + return $shop; + } +} diff --git a/app/Models/Htpms/MstCustomer.php b/app/Models/Htpms/MstCustomer.php index 1ec1990..5d65e1b 100644 --- a/app/Models/Htpms/MstCustomer.php +++ b/app/Models/Htpms/MstCustomer.php @@ -14,4 +14,9 @@ class MstCustomer extends Model protected $table = 'mst_customer'; protected $fillable = []; // 参照専用 + protected $visible = [ + self::COL_NAME_ID, + self::COL_NAME_CUSTOMER_ID, + self::COL_NAME_CUSTOMER_NAME, + ]; } diff --git a/app/Models/User.php b/app/Models/User.php index bf418a2..cd34764 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -76,7 +76,8 @@ class User extends Authenticatable implements IModelFeature public static function getBuilder(string $name = 'main'): Builder { - return DB::table(static::getTableName(), $name); + $instance = new static(); + return DB::connection($instance->getConnectionName())->table(static::getTableName(), $name); } public static function getTableName(): string diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index c394511..cfd3890 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -24,11 +24,8 @@ class RouteServiceProvider extends ServiceProvider */ public function boot(): void { - // RateLimiter::for('api', function (Request $request) { - // return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); - // }); - RateLimiter::for('web', function (Request $request) { - return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(1000)->by($request->user()?->id ?: $request->ip()); }); $this->routes(function () { diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php new file mode 100644 index 0000000..702bfa5 --- /dev/null +++ b/app/Repositories/BaseRepository.php @@ -0,0 +1,81 @@ +orderBy($target); + } + if ($order === static::ORDER_DESC) { + $query->orderByDesc($target); + } + } + + protected function limit(Builder $query, array $condition, ?int $default = null) + { + + + $limit = data_get($condition, self::CONDITION_LIMIT, $default) ?? $default ?? static::MAX_LIMIT; + + $limit = min($limit, self::MAX_LIMIT); + + $query->limit($limit); + } + + protected function where(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool + { + + $ret = data_get($condition, $conditionKey); + if ($ret !== null) { + $query->where($columnName ?? $conditionKey, $ret); + return true; + } else { + return false; + } + } + protected function whereIn(Builder $query, array $condition, string $conditionKey, string|null $columnName = null): bool + { + + $ret = data_get($condition, $conditionKey); + if ($ret !== null && is_array($ret)) { + $query->whereIn($columnName ?? $conditionKey, $ret); + return true; + } else { + return false; + } + } + + protected function makeColumnName(array $targets, ?string $as = null): string + { + $as = $as ? " as {$as}" : ""; + return implode('.', $targets) . $as; + } + protected function makeColumnNameForSelect(array $targets, ?string $as = null): string + { + $as = $as ? " as {$as}" : " as " . Arr::last($targets); + return implode('.', $targets) . $as; + } +} diff --git a/app/Repositories/BaseRepositoryData.php b/app/Repositories/BaseRepositoryData.php new file mode 100644 index 0000000..e638fb1 --- /dev/null +++ b/app/Repositories/BaseRepositoryData.php @@ -0,0 +1,34 @@ + $val) { + $this->$key = $val; + } + } + + /** + * @param Collection $list + * @return Collection + */ + static public function makeList(Collection $list) + { + $ret = collect(); + foreach ($list as $data) { + $ret->push(new static($data)); + } + return $ret; + } + + public function toArray(): array + { + return json_decode(json_encode($this), true); + } +} diff --git a/app/Repositories/LoginUserRepository.php b/app/Repositories/LoginUserRepository.php new file mode 100644 index 0000000..7f12473 --- /dev/null +++ b/app/Repositories/LoginUserRepository.php @@ -0,0 +1,90 @@ + + */ + public function get(array $condition): Collection + { + + $table = User::getBuilder(static::TABLE_USER); + + $table->leftJoinSub(MstCustomer::getBuilder(), static::TABLE_CUSTOMER, function (JoinClause $join) { + $join->on( + $this->makeColumnName([static::TABLE_USER, User::COL_NAME_CUSTOMER_CODE]), + $this->makeColumnName([static::TABLE_CUSTOMER, MstCustomer::COL_NAME_CUSTOMER_ID]) + ); + }); + + + // -----検索条件 + // ID + $this->where($table, $condition, static::CONDITION_ID, $this->makeColumnName([static::TABLE_USER, User::COL_NAME_ID])); + + // 名前 + $name = data_get($condition, static::CONDITION_NAME); + if ($name) { + $table->where($this->makeColumnName([static::TABLE_USER, User::COL_NAME_NAME]), 'like', "%{$name}%"); + } + + // EMAIL + $email = data_get($condition, static::CONDITION_EMAIL); + if ($email) { + $table->where($this->makeColumnName([static::TABLE_USER, User::COL_NAME_EMAIL]), 'like', "%{$email}%"); + } + // ROLE + $this->where($table, $condition, static::CONDITION_ROLE, $this->makeColumnName([static::TABLE_USER, User::COL_NAME_ROLE])); + + $table->select($this->columns()); + + $main = DB::connection("htpms")->table($table, "main"); + + // ソート + $this->sort($main, $condition); + $main->orderBy(static::CONDITION_ID); + + // リミット + $this->limit($main, $condition); + + + return LoginUserRepositoryData::makeList($main->get()); + } + + private function columns() + { + $user = static::TABLE_USER; + $customer = static::TABLE_CUSTOMER; + $columns = [ + $this->makeColumnNameForSelect([$user, User::COL_NAME_ID]), + $this->makeColumnNameForSelect([$user, User::COL_NAME_NAME]), + $this->makeColumnNameForSelect([$user, User::COL_NAME_EMAIL]), + $this->makeColumnNameForSelect([$user, User::COL_NAME_CUSTOMER_CODE]), + $this->makeColumnNameForSelect([$customer, MstCustomer::COL_NAME_CUSTOMER_NAME]), + ]; + + + return $columns; + } +} diff --git a/app/Repositories/LoginUserRepositoryData.php b/app/Repositories/LoginUserRepositoryData.php new file mode 100644 index 0000000..a87598e --- /dev/null +++ b/app/Repositories/LoginUserRepositoryData.php @@ -0,0 +1,13 @@ + + */ + public function get(array $condition): Collection + { + + $table = Shop::getBuilder(static::TABLE_SHOP); + + $table->leftJoinSub(Deposit::getBuilder(), static::TABLE_DEPOSIT, function (JoinClause $join) { + $join->on( + $this->makeColumnName([static::TABLE_SHOP, Shop::COL_NAME_ID]), + $this->makeColumnName([static::TABLE_DEPOSIT, Deposit::COL_NAME_SHOP_ID]) + ); + }); + + // -----検索条件 + // SHOP_ID + $this->where($table, $condition, static::CONDITION_SHOP_ID, $this->makeColumnName([static::TABLE_SHOP, Shop::COL_NAME_ID])); + + // 名前 + $name = data_get($condition, static::CONDITION_NAME); + if ($name) { + $table->where($this->makeColumnName([static::TABLE_SHOP, Shop::COL_NAME_NAME]), 'like', "%{$name}%"); + } + + + $table->select($this->columns()); + + $main = DB::connection("htpms_customer")->table($table, "main"); + + // ソート + $this->sort($main, $condition); + $main->orderBy(static::CONDITION_SHOP_ID); + + // リミット + $this->limit($main, $condition); + + + return LoginUserRepositoryData::makeList($main->get()); + } + + private function columns() + { + $shop = static::TABLE_SHOP; + $deposit = static::TABLE_DEPOSIT; + $columns = [ + $this->makeColumnNameForSelect([$deposit, Deposit::COL_NAME_SHOP_ID]), + $this->makeColumnNameForSelect([$deposit, Deposit::COL_NAME_DEPOSIT]), + $this->makeColumnNameForSelect([$shop, User::COL_NAME_NAME]), + ]; + + return $columns; + } +} diff --git a/app/Repositories/ShopRepositoryData.php b/app/Repositories/ShopRepositoryData.php new file mode 100644 index 0000000..927a225 --- /dev/null +++ b/app/Repositories/ShopRepositoryData.php @@ -0,0 +1,13 @@ +isSwtiched; } + public function shopId(): string + { + if ($this->user === null) throw new LogicException(); + if ($this->user->shop_id === null) throw new LogicException(); + return $this->user->shop_id; + } + + public function customerCode(): string + { + if ($this->user === null) throw new LogicException(); + if ($this->user->customer_code === null) throw new LogicException(); + return $this->user->customer_code; + } + private function getStoreKey(string $key): string { return sprintf("%s-%s", self::class, $key); diff --git a/lang/en/auth.php b/lang/en/auth.php new file mode 100644 index 0000000..6598e2c --- /dev/null +++ b/lang/en/auth.php @@ -0,0 +1,20 @@ + 'These credentials do not match our records.', + 'password' => 'The provided password is incorrect.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/lang/en/pagination.php b/lang/en/pagination.php new file mode 100644 index 0000000..d481411 --- /dev/null +++ b/lang/en/pagination.php @@ -0,0 +1,19 @@ + '« Previous', + 'next' => 'Next »', + +]; diff --git a/lang/en/passwords.php b/lang/en/passwords.php new file mode 100644 index 0000000..f1223bd --- /dev/null +++ b/lang/en/passwords.php @@ -0,0 +1,22 @@ + 'Your password has been reset.', + 'sent' => 'We have emailed your password reset link.', + 'throttled' => 'Please wait before retrying.', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that email address.", + +]; diff --git a/lang/en/validation.php b/lang/en/validation.php new file mode 100644 index 0000000..99f7c61 --- /dev/null +++ b/lang/en/validation.php @@ -0,0 +1,184 @@ + 'The :attribute field must be accepted.', + 'accepted_if' => 'The :attribute field must be accepted when :other is :value.', + 'active_url' => 'The :attribute field must be a valid URL.', + 'after' => 'The :attribute field must be a date after :date.', + 'after_or_equal' => 'The :attribute field must be a date after or equal to :date.', + 'alpha' => 'The :attribute field must only contain letters.', + 'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.', + 'alpha_num' => 'The :attribute field must only contain letters and numbers.', + 'array' => 'The :attribute field must be an array.', + 'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.', + 'before' => 'The :attribute field must be a date before :date.', + 'before_or_equal' => 'The :attribute field must be a date before or equal to :date.', + 'between' => [ + 'array' => 'The :attribute field must have between :min and :max items.', + 'file' => 'The :attribute field must be between :min and :max kilobytes.', + 'numeric' => 'The :attribute field must be between :min and :max.', + 'string' => 'The :attribute field must be between :min and :max characters.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute field must be a valid date.', + 'date_equals' => 'The :attribute field must be a date equal to :date.', + 'date_format' => 'The :attribute field must match the format :format.', + 'decimal' => 'The :attribute field must have :decimal decimal places.', + 'declined' => 'The :attribute field must be declined.', + 'declined_if' => 'The :attribute field must be declined when :other is :value.', + 'different' => 'The :attribute field and :other must be different.', + 'digits' => 'The :attribute field must be :digits digits.', + 'digits_between' => 'The :attribute field must be between :min and :max digits.', + 'dimensions' => 'The :attribute field has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.', + 'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.', + 'email' => 'The :attribute field must be a valid email address.', + 'ends_with' => 'The :attribute field must end with one of the following: :values.', + 'enum' => 'The selected :attribute is invalid.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute field must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'array' => 'The :attribute field must have more than :value items.', + 'file' => 'The :attribute field must be greater than :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than :value.', + 'string' => 'The :attribute field must be greater than :value characters.', + ], + 'gte' => [ + 'array' => 'The :attribute field must have :value items or more.', + 'file' => 'The :attribute field must be greater than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than or equal to :value.', + 'string' => 'The :attribute field must be greater than or equal to :value characters.', + ], + 'image' => 'The :attribute field must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field must exist in :other.', + 'integer' => 'The :attribute field must be an integer.', + 'ip' => 'The :attribute field must be a valid IP address.', + 'ipv4' => 'The :attribute field must be a valid IPv4 address.', + 'ipv6' => 'The :attribute field must be a valid IPv6 address.', + 'json' => 'The :attribute field must be a valid JSON string.', + 'lowercase' => 'The :attribute field must be lowercase.', + 'lt' => [ + 'array' => 'The :attribute field must have less than :value items.', + 'file' => 'The :attribute field must be less than :value kilobytes.', + 'numeric' => 'The :attribute field must be less than :value.', + 'string' => 'The :attribute field must be less than :value characters.', + ], + 'lte' => [ + 'array' => 'The :attribute field must not have more than :value items.', + 'file' => 'The :attribute field must be less than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be less than or equal to :value.', + 'string' => 'The :attribute field must be less than or equal to :value characters.', + ], + 'mac_address' => 'The :attribute field must be a valid MAC address.', + 'max' => [ + 'array' => 'The :attribute field must not have more than :max items.', + 'file' => 'The :attribute field must not be greater than :max kilobytes.', + 'numeric' => 'The :attribute field must not be greater than :max.', + 'string' => 'The :attribute field must not be greater than :max characters.', + ], + 'max_digits' => 'The :attribute field must not have more than :max digits.', + 'mimes' => 'The :attribute field must be a file of type: :values.', + 'mimetypes' => 'The :attribute field must be a file of type: :values.', + 'min' => [ + 'array' => 'The :attribute field must have at least :min items.', + 'file' => 'The :attribute field must be at least :min kilobytes.', + 'numeric' => 'The :attribute field must be at least :min.', + 'string' => 'The :attribute field must be at least :min characters.', + ], + 'min_digits' => 'The :attribute field must have at least :min digits.', + 'missing' => 'The :attribute field must be missing.', + 'missing_if' => 'The :attribute field must be missing when :other is :value.', + 'missing_unless' => 'The :attribute field must be missing unless :other is :value.', + 'missing_with' => 'The :attribute field must be missing when :values is present.', + 'missing_with_all' => 'The :attribute field must be missing when :values are present.', + 'multiple_of' => 'The :attribute field must be a multiple of :value.', + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute field format is invalid.', + 'numeric' => 'The :attribute field must be a number.', + 'password' => [ + 'letters' => 'The :attribute field must contain at least one letter.', + 'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.', + 'numbers' => 'The :attribute field must contain at least one number.', + 'symbols' => 'The :attribute field must contain at least one symbol.', + 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', + ], + 'present' => 'The :attribute field must be present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'prohibits' => 'The :attribute field prohibits :other from being present.', + 'regex' => 'The :attribute field format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_array_keys' => 'The :attribute field must contain entries for: :values.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'same' => 'The :attribute field must match :other.', + 'size' => [ + 'array' => 'The :attribute field must contain :size items.', + 'file' => 'The :attribute field must be :size kilobytes.', + 'numeric' => 'The :attribute field must be :size.', + 'string' => 'The :attribute field must be :size characters.', + ], + 'starts_with' => 'The :attribute field must start with one of the following: :values.', + 'string' => 'The :attribute field must be a string.', + 'timezone' => 'The :attribute field must be a valid timezone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'uppercase' => 'The :attribute field must be uppercase.', + 'url' => 'The :attribute field must be a valid URL.', + 'ulid' => 'The :attribute field must be a valid ULID.', + 'uuid' => 'The :attribute field must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + +]; diff --git a/lang/ja/auth.php b/lang/ja/auth.php new file mode 100644 index 0000000..6598e2c --- /dev/null +++ b/lang/ja/auth.php @@ -0,0 +1,20 @@ + 'These credentials do not match our records.', + 'password' => 'The provided password is incorrect.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/lang/ja/pagination.php b/lang/ja/pagination.php new file mode 100644 index 0000000..d481411 --- /dev/null +++ b/lang/ja/pagination.php @@ -0,0 +1,19 @@ + '« Previous', + 'next' => 'Next »', + +]; diff --git a/lang/ja/passwords.php b/lang/ja/passwords.php new file mode 100644 index 0000000..f1223bd --- /dev/null +++ b/lang/ja/passwords.php @@ -0,0 +1,22 @@ + 'Your password has been reset.', + 'sent' => 'We have emailed your password reset link.', + 'throttled' => 'Please wait before retrying.', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that email address.", + +]; diff --git a/lang/ja/validation.php b/lang/ja/validation.php new file mode 100644 index 0000000..9ba9f01 --- /dev/null +++ b/lang/ja/validation.php @@ -0,0 +1,205 @@ + 'The :attribute field must be accepted.', + 'accepted_if' => 'The :attribute field must be accepted when :other is :value.', + 'active_url' => 'The :attribute field must be a valid URL.', + 'after' => 'The :attribute field must be a date after :date.', + 'after_or_equal' => 'The :attribute field must be a date after or equal to :date.', + 'alpha' => 'The :attribute field must only contain letters.', + 'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.', + 'alpha_num' => 'The :attribute field must only contain letters and numbers.', + 'array' => 'The :attribute field must be an array.', + 'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.', + 'before' => 'The :attribute field must be a date before :date.', + 'before_or_equal' => 'The :attribute field must be a date before or equal to :date.', + 'between' => [ + 'array' => 'The :attribute field must have between :min and :max items.', + 'file' => 'The :attribute field must be between :min and :max kilobytes.', + 'numeric' => 'The :attribute field must be between :min and :max.', + 'string' => 'The :attribute field must be between :min and :max characters.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute field must be a valid date.', + 'date_equals' => 'The :attribute field must be a date equal to :date.', + 'date_format' => 'The :attribute field must match the format :format.', + 'decimal' => 'The :attribute field must have :decimal decimal places.', + 'declined' => 'The :attribute field must be declined.', + 'declined_if' => 'The :attribute field must be declined when :other is :value.', + 'different' => 'The :attribute field and :other must be different.', + 'digits' => 'The :attribute field must be :digits digits.', + 'digits_between' => 'The :attribute field must be between :min and :max digits.', + 'dimensions' => 'The :attribute field has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.', + 'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.', + 'email' => 'The :attribute field must be a valid email address.', + 'ends_with' => 'The :attribute field must end with one of the following: :values.', + 'enum' => 'The selected :attribute is invalid.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute field must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'array' => 'The :attribute field must have more than :value items.', + 'file' => 'The :attribute field must be greater than :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than :value.', + 'string' => 'The :attribute field must be greater than :value characters.', + ], + 'gte' => [ + 'array' => 'The :attribute field must have :value items or more.', + 'file' => 'The :attribute field must be greater than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than or equal to :value.', + 'string' => 'The :attribute field must be greater than or equal to :value characters.', + ], + 'image' => 'The :attribute field must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field must exist in :other.', + 'integer' => 'The :attribute field must be an integer.', + 'ip' => 'The :attribute field must be a valid IP address.', + 'ipv4' => 'The :attribute field must be a valid IPv4 address.', + 'ipv6' => 'The :attribute field must be a valid IPv6 address.', + 'json' => 'The :attribute field must be a valid JSON string.', + 'lowercase' => 'The :attribute field must be lowercase.', + 'lt' => [ + 'array' => 'The :attribute field must have less than :value items.', + 'file' => 'The :attribute field must be less than :value kilobytes.', + 'numeric' => 'The :attribute field must be less than :value.', + 'string' => 'The :attribute field must be less than :value characters.', + ], + 'lte' => [ + 'array' => 'The :attribute field must not have more than :value items.', + 'file' => 'The :attribute field must be less than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be less than or equal to :value.', + 'string' => 'The :attribute field must be less than or equal to :value characters.', + ], + 'mac_address' => 'The :attribute field must be a valid MAC address.', + 'max' => [ + 'array' => 'The :attribute field must not have more than :max items.', + 'file' => 'The :attribute field must not be greater than :max kilobytes.', + 'numeric' => 'The :attribute field must not be greater than :max.', + 'string' => 'The :attribute field must not be greater than :max characters.', + ], + 'max_digits' => 'The :attribute field must not have more than :max digits.', + 'mimes' => 'The :attribute field must be a file of type: :values.', + 'mimetypes' => 'The :attribute field must be a file of type: :values.', + 'min' => [ + 'array' => 'The :attribute field must have at least :min items.', + 'file' => 'The :attribute field must be at least :min kilobytes.', + 'numeric' => 'The :attribute field must be at least :min.', + 'string' => 'The :attribute field must be at least :min characters.', + ], + 'min_digits' => 'The :attribute field must have at least :min digits.', + 'missing' => 'The :attribute field must be missing.', + 'missing_if' => 'The :attribute field must be missing when :other is :value.', + 'missing_unless' => 'The :attribute field must be missing unless :other is :value.', + 'missing_with' => 'The :attribute field must be missing when :values is present.', + 'missing_with_all' => 'The :attribute field must be missing when :values are present.', + 'multiple_of' => 'The :attribute field must be a multiple of :value.', + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute field format is invalid.', + 'numeric' => 'The :attribute field must be a number.', + 'password' => [ + 'letters' => 'The :attribute field must contain at least one letter.', + 'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.', + 'numbers' => 'The :attribute field must contain at least one number.', + 'symbols' => 'The :attribute field must contain at least one symbol.', + 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', + ], + 'present' => 'The :attribute field must be present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'prohibits' => 'The :attribute field prohibits :other from being present.', + 'regex' => 'The :attribute field format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_array_keys' => 'The :attribute field must contain entries for: :values.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'same' => 'The :attribute field must match :other.', + 'size' => [ + 'array' => 'The :attribute field must contain :size items.', + 'file' => 'The :attribute field must be :size kilobytes.', + 'numeric' => 'The :attribute field must be :size.', + 'string' => 'The :attribute field must be :size characters.', + ], + 'starts_with' => 'The :attribute field must start with one of the following: :values.', + 'string' => 'The :attribute field must be a string.', + 'timezone' => 'The :attribute field must be a valid timezone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'uppercase' => 'The :attribute field must be uppercase.', + 'url' => 'The :attribute field must be a valid URL.', + 'ulid' => 'The :attribute field must be a valid ULID.', + 'uuid' => 'The :attribute field must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + +], [ + 'after' => '日付の前後関係が正しくありません', + 'after_or_equal' => '日付の前後関係が正しくありません', + 'before_or_equal' => '日付の前後関係が正しくありません', + 'between' => [ + 'string' => ':min から :max 文字入力してください', + ], + 'date' => '日付を入力してください', + 'email' => 'Emailの形式が正しくありません', + 'enum' => '正しい項目を選択してください', + 'exists' => '存在しません', + 'max' => [ + 'string' => ':max 文字まで入力できます', + ], + 'numeric' => '数値を入力してください', + 'required' => '必須項目です', + 'size' => [ + 'string' => ':size 桁で入力してください.', + ], + 'string' => '文字を入力してください', + 'unique' => 'すでに使われています', +]); diff --git a/routes/api.php b/routes/api.php index 685d0c1..316b018 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,9 +23,28 @@ RouteHelper::get('/qr-service/get-ticket', App\Http\Controllers\Web\QRService\Cr Route::middleware('auth:sanctum')->group(function () { + // 管理者ルート Route::middleware(RouteHelper::role([UserRole::ADMIN]))->group(function () { + RouteHelper::get('/customer/list', App\Http\Controllers\Web\Customer\CustomerListController::class); + RouteHelper::get('/login-user/customer/list', App\Http\Controllers\Web\LoginUser\CustomerListController::class); + RouteHelper::get('/login-user/customer/register', App\Http\Controllers\Web\LoginUser\CustomerRegisterController::class); + RouteHelper::get('/login-user/shop/register', App\Http\Controllers\Web\LoginUser\CustomerRegisterController::class); }); + // 運営会社ルート + Route::middleware(RouteHelper::role([UserRole::CUSTOMER]))->group(function () { + RouteHelper::post('/login-user/shop/register', App\Http\Controllers\Web\LoginUser\ShopRegisterController::class); + RouteHelper::post('/shop/register', App\Http\Controllers\Web\Shop\ShopRegisterController::class); + RouteHelper::post('/shop/list', App\Http\Controllers\Web\Shop\ShopListController::class); + }); + + // 店舗ルート + Route::middleware(RouteHelper::role([UserRole::SHOP]))->group(function () { + RouteHelper::get('/shop/deposit', App\Http\Controllers\Web\Shop\MyDepositController::class); + RouteHelper::post('/shop/deposit/charge', App\Http\Controllers\Web\Shop\DepositChargeController::class); + }); + + // 管理者と運営会社ルート Route::middleware(RouteHelper::role([UserRole::ADMIN, UserRole::CUSTOMER]))->group(function () { RouteHelper::post('/role/switch', App\Http\Controllers\Web\Auth\SwitchController::class); RouteHelper::get('/role/switch/end', App\Http\Controllers\Web\Auth\SwitchEndController::class);