| @@ -0,0 +1,17 @@ | |||||
| <?php | |||||
| namespace App\Exceptions; | |||||
| use Exception; | |||||
| class ParamException extends Exception | |||||
| { | |||||
| public string $target; | |||||
| public static function throw(string $target, $message) | |||||
| { | |||||
| $exception = new static($message); | |||||
| $exception->target = $target; | |||||
| throw $exception; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,39 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Customer; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Models\Htpms\MstCustomer; | |||||
| use App\Repositories\LoginUserRepository; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class CustomerListController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "運営会社一覧取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "運営会社一覧を取得する"; | |||||
| } | |||||
| public function __construct(protected CustomerListParam $param, private LoginUserRepository $repository) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $list = MstCustomer::all(); | |||||
| $res = [ | |||||
| "list" => $list->toArray(), | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Customer; | |||||
| use App\Http\Controllers\Web\NoneParams; | |||||
| class CustomerListParam extends NoneParams | |||||
| { | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Codes\UserRole; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Repositories\LoginUserRepository; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class CustomerListController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "運営会社ログインユーザ一覧取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "運営会社ログインユーザ一覧を取得する"; | |||||
| } | |||||
| public function __construct(protected CustomerListParam $param, private LoginUserRepository $repository) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->param; | |||||
| $list = $this->repository->get([ | |||||
| ...$param->toArray(), | |||||
| LoginUserRepository::CONDITION_ROLE => UserRole::CUSTOMER->value, | |||||
| ]); | |||||
| $res = [ | |||||
| "list" => $list, | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,23 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Http\Controllers\Web\SortableParam; | |||||
| use App\Repositories\LoginUserRepository; | |||||
| /** | |||||
| * @property ?string name | |||||
| * @property ?string $email | |||||
| */ | |||||
| class CustomerListParam extends BaseParam implements SortableParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| LoginUserRepository::CONDITION_EMAIL => $this->str(true), | |||||
| LoginUserRepository::CONDITION_NAME => $this->str(true), | |||||
| ...$this->sortableRules(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\LoginUser\LoginUserLogic; | |||||
| use App\Models\User; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class CustomerRegisterController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "運営会社ログインユーザ新規登録"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "運営会社ログインユーザを新規登録する"; | |||||
| } | |||||
| public function __construct(protected CustomerRegisterParam $param, protected LoginUserLogic $logic) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Http\Controllers\Web\Rule; | |||||
| use App\Models\User; | |||||
| use App\Rules\LoginPassword; | |||||
| /** | |||||
| * @property string name | |||||
| * @property string email | |||||
| * @property string password | |||||
| * @property string customerCode | |||||
| */ | |||||
| class CustomerRegisterParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| User::COL_NAME_NAME => $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(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,50 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\LoginUser\LoginUserLogic; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\User; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class ShopRegisterController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "店舗ログインユーザ新規登録"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "店舗ログインユーザを新規登録する"; | |||||
| } | |||||
| public function __construct(protected ShopRegisterParam $param, protected LoginUserLogic $logic) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $this->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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\LoginUser; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Http\Controllers\Web\Rule; | |||||
| use App\Models\User; | |||||
| use App\Rules\LoginPassword; | |||||
| /** | |||||
| * @property string shopId | |||||
| * @property string name | |||||
| * @property string email | |||||
| * @property string password | |||||
| */ | |||||
| class ShopRegisterParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| User::COL_NAME_SHOP_ID => $this->str(), | |||||
| User::COL_NAME_NAME => $this->str(), | |||||
| User::COL_NAME_EMAIL => $this->str([...Rule::email()]), | |||||
| User::COL_NAME_PASSWORD => $this->str([new LoginPassword()]), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,53 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\QRService\ChargeLogic; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use LogicException; | |||||
| class DepositChargeController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "デポジットチャージ"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "デポジットをチャージする"; | |||||
| } | |||||
| public function __construct(protected DepositChargeParam $param, protected ChargeLogic $logic) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,21 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | |||||
| /** | |||||
| * @property string shopId | |||||
| * @property int amount | |||||
| */ | |||||
| class DepositChargeParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| Deposit::COL_NAME_SHOP_ID => $this->str(), | |||||
| Deposit::COL_NAME_DEPOSIT => $this->numeric(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,43 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use LogicException; | |||||
| class MyDepositController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "デポジット情報取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "デポジット情報を取得する"; | |||||
| } | |||||
| public function __construct(protected MyDepositParam $param) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $user = $this->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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\NoneParams; | |||||
| class MyDepositParam extends NoneParams | |||||
| { | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Repositories\ShopRepository; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| class ShopListController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "店舗一覧取得"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "店舗一覧を取得する"; | |||||
| } | |||||
| public function __construct(protected ShopListParam $param, private ShopRepository $repository) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $list = $this->repository->get([ | |||||
| ...$this->param->toArray(), | |||||
| ]); | |||||
| $res = [ | |||||
| "list" => $list | |||||
| ]; | |||||
| return $this->successResponse($res); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\NoneParams; | |||||
| class ShopListParam extends NoneParams | |||||
| { | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\WebController; | |||||
| use App\Logics\LoginUser\LoginUserLogic; | |||||
| use App\Logics\Shop\ShopLogic; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\User; | |||||
| use Illuminate\Http\JsonResponse; | |||||
| use Illuminate\Http\Request; | |||||
| use LogicException; | |||||
| class ShopRegisterController extends WebController | |||||
| { | |||||
| public function name(): string | |||||
| { | |||||
| return "店舗マスタ新規登録"; | |||||
| } | |||||
| public function description(): string | |||||
| { | |||||
| return "店舗マスタを新規登録する"; | |||||
| } | |||||
| public function __construct(protected ShopRegisterParam $param, protected ShopLogic $logic) | |||||
| { | |||||
| parent::__construct(); | |||||
| } | |||||
| protected function run(Request $request): JsonResponse | |||||
| { | |||||
| $param = $this->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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| <?php | |||||
| namespace App\Http\Controllers\Web\Shop; | |||||
| use App\Http\Controllers\Web\BaseParam; | |||||
| use App\Models\User; | |||||
| /** | |||||
| * @property string name | |||||
| */ | |||||
| class ShopRegisterParam extends BaseParam | |||||
| { | |||||
| public function rules(): array | |||||
| { | |||||
| return [ | |||||
| User::COL_NAME_NAME => $this->str(), | |||||
| ]; | |||||
| } | |||||
| } | |||||
| @@ -8,6 +8,7 @@ use App\Codes\UserRole; | |||||
| use App\Exceptions\AppCommonException; | use App\Exceptions\AppCommonException; | ||||
| use App\Exceptions\ExclusiveException; | use App\Exceptions\ExclusiveException; | ||||
| use App\Exceptions\GeneralErrorMessageException; | use App\Exceptions\GeneralErrorMessageException; | ||||
| use App\Exceptions\ParamException; | |||||
| use App\Sessions\SessionUser; | use App\Sessions\SessionUser; | ||||
| use App\Util\DBUtil; | use App\Util\DBUtil; | ||||
| use Exception; | use Exception; | ||||
| @@ -210,6 +211,9 @@ abstract class WebController extends BaseController | |||||
| return $this->unAuthorizedResponse(); | return $this->unAuthorizedResponse(); | ||||
| } | } | ||||
| throw $e; | throw $e; | ||||
| } catch (ParamException $e) { | |||||
| $this->transaction->rollBack(); | |||||
| throw $this->validateErrorResponse([$e->target => $e->getMessage()]); | |||||
| } catch (Exception $e) { | } catch (Exception $e) { | ||||
| $this->transaction->rollBack(); | $this->transaction->rollBack(); | ||||
| logs()->error([ | logs()->error([ | ||||
| @@ -0,0 +1,62 @@ | |||||
| <?php | |||||
| namespace App\Logics\LoginUser; | |||||
| use App\Codes\UserRole; | |||||
| use App\Exceptions\ParamException; | |||||
| use App\Models\Htpms\MstCustomer; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\User; | |||||
| class LoginUserLogic | |||||
| { | |||||
| private User|null $user = null; | |||||
| public function createCustomerUser(User $user) | |||||
| { | |||||
| $this->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; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| <?php | |||||
| namespace App\Logics\QRService; | |||||
| class ChargeLogic | |||||
| { | |||||
| use DepositCheck; | |||||
| /** | |||||
| * デポジットをチャージする | |||||
| */ | |||||
| public static function charge( | |||||
| string $shopId, | |||||
| int $amount, | |||||
| ) { | |||||
| [$shop, $deposit] = self::getData($shopId); | |||||
| $deposit->deposit += $amount; | |||||
| self::makeTransferHistory($shopId, $amount); | |||||
| return $deposit; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| <?php | |||||
| namespace App\Logics\Shop; | |||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\User; | |||||
| class ShopLogic | |||||
| { | |||||
| private User|null $customerUser = null; | |||||
| private Shop|null $shop = null; | |||||
| public function create(User $customerUser, Shop $shop) | |||||
| { | |||||
| $this->customerUser = $customerUser; | |||||
| $this->shop = $shop; | |||||
| // チェック処理 | |||||
| $shop->save(); | |||||
| // デポジット | |||||
| $deposit = new Deposit(); | |||||
| $deposit->shop_id = $shop->idl; | |||||
| $deposit->save(); | |||||
| return $shop; | |||||
| } | |||||
| } | |||||
| @@ -14,4 +14,9 @@ class MstCustomer extends Model | |||||
| protected $table = 'mst_customer'; | protected $table = 'mst_customer'; | ||||
| protected $fillable = []; // 参照専用 | protected $fillable = []; // 参照専用 | ||||
| protected $visible = [ | |||||
| self::COL_NAME_ID, | |||||
| self::COL_NAME_CUSTOMER_ID, | |||||
| self::COL_NAME_CUSTOMER_NAME, | |||||
| ]; | |||||
| } | } | ||||
| @@ -76,7 +76,8 @@ class User extends Authenticatable implements IModelFeature | |||||
| public static function getBuilder(string $name = 'main'): Builder | 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 | public static function getTableName(): string | ||||
| @@ -24,11 +24,8 @@ class RouteServiceProvider extends ServiceProvider | |||||
| */ | */ | ||||
| public function boot(): void | 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 () { | $this->routes(function () { | ||||
| @@ -0,0 +1,81 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| use Illuminate\Database\Query\Builder; | |||||
| use Illuminate\Support\Arr; | |||||
| abstract class BaseRepository | |||||
| { | |||||
| const ORDER_ASC = "asc"; | |||||
| const ORDER_DESC = "desc"; | |||||
| const CONDITION_SORT_TARGET = "sort"; | |||||
| const CONDITION_SORT_ORDER = "order"; | |||||
| const CONDITION_LIMIT = "limit"; | |||||
| const MAX_LIMIT = 500; | |||||
| protected function sort(Builder $query, array $condition) | |||||
| { | |||||
| $target = data_get($condition, self::CONDITION_SORT_TARGET); | |||||
| $order = data_get($condition, self::CONDITION_SORT_ORDER); | |||||
| if ($target === null || $order === null) { | |||||
| return; | |||||
| } | |||||
| if ($order === static::ORDER_ASC) { | |||||
| $query->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; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,34 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| use Illuminate\Support\Collection; | |||||
| use stdClass; | |||||
| class BaseRepositoryData extends stdClass | |||||
| { | |||||
| public function __construct(stdClass $data) | |||||
| { | |||||
| foreach ($data as $key => $val) { | |||||
| $this->$key = $val; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * @param Collection<stdClass> $list | |||||
| * @return Collection<static> | |||||
| */ | |||||
| 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); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| use App\Models\Htpms\MstCustomer; | |||||
| use App\Models\User; | |||||
| use App\Repositories\BaseRepository; | |||||
| use Illuminate\Support\Collection; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| class LoginUserRepository extends BaseRepository | |||||
| { | |||||
| const CONDITION_ID = 'id'; | |||||
| const CONDITION_NAME = 'name'; | |||||
| const CONDITION_ROLE = 'role'; | |||||
| const CONDITION_EMAIL = 'email'; | |||||
| const TABLE_USER = "user"; | |||||
| const TABLE_CUSTOMER = "customer"; | |||||
| /** | |||||
| * コレクションを取得する | |||||
| * | |||||
| * @param array $condition | |||||
| * @return Collection<LoginUserRepositoryData> | |||||
| */ | |||||
| 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 = 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; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| /** | |||||
| * @property string id | |||||
| * @property string name | |||||
| * @property string email | |||||
| */ | |||||
| class LoginUserRepositoryData extends BaseRepositoryData | |||||
| { | |||||
| } | |||||
| @@ -0,0 +1,78 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| use App\Models\HtpmsCustomer\Deposit\Deposit; | |||||
| use App\Models\HtpmsCustomer\Mst\Shop; | |||||
| use App\Models\User; | |||||
| use App\Repositories\BaseRepository; | |||||
| use Illuminate\Support\Collection; | |||||
| use Illuminate\Support\Facades\DB; | |||||
| class ShopRepository extends BaseRepository | |||||
| { | |||||
| const CONDITION_SHOP_ID = 'shop_id'; | |||||
| const CONDITION_NAME = 'name'; | |||||
| const TABLE_SHOP = "shop"; | |||||
| const TABLE_DEPOSIT = "deposit"; | |||||
| /** | |||||
| * コレクションを取得する | |||||
| * | |||||
| * @param array $condition | |||||
| * @return Collection<ShopRepositoryData> | |||||
| */ | |||||
| 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; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?php | |||||
| namespace App\Repositories; | |||||
| /** | |||||
| * @property string shop_id | |||||
| * @property int deposit | |||||
| * @property string name | |||||
| */ | |||||
| class ShopRepositoryData extends BaseRepositoryData | |||||
| { | |||||
| } | |||||
| @@ -94,6 +94,20 @@ class SessionUser | |||||
| return $this->isSwtiched; | return $this->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 | private function getStoreKey(string $key): string | ||||
| { | { | ||||
| return sprintf("%s-%s", self::class, $key); | return sprintf("%s-%s", self::class, $key); | ||||
| @@ -0,0 +1,20 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Authentication Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are used during authentication for various | |||||
| | messages that we need to display to the user. You are free to modify | |||||
| | these language lines according to your application's requirements. | |||||
| | | |||||
| */ | |||||
| 'failed' => 'These credentials do not match our records.', | |||||
| 'password' => 'The provided password is incorrect.', | |||||
| 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', | |||||
| ]; | |||||
| @@ -0,0 +1,19 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Pagination Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are used by the paginator library to build | |||||
| | the simple pagination links. You are free to change them to anything | |||||
| | you want to customize your views to better match your application. | |||||
| | | |||||
| */ | |||||
| 'previous' => '« Previous', | |||||
| 'next' => 'Next »', | |||||
| ]; | |||||
| @@ -0,0 +1,22 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Password Reset Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are the default lines which match reasons | |||||
| | that are given by the password broker for a password update attempt | |||||
| | has failed, such as for an invalid token or invalid new password. | |||||
| | | |||||
| */ | |||||
| 'reset' => '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.", | |||||
| ]; | |||||
| @@ -0,0 +1,184 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Validation Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines contain the default error messages used by | |||||
| | the validator class. Some of these rules have multiple versions such | |||||
| | as the size rules. Feel free to tweak each of these messages here. | |||||
| | | |||||
| */ | |||||
| 'accepted' => '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' => [], | |||||
| ]; | |||||
| @@ -0,0 +1,20 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Authentication Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are used during authentication for various | |||||
| | messages that we need to display to the user. You are free to modify | |||||
| | these language lines according to your application's requirements. | |||||
| | | |||||
| */ | |||||
| 'failed' => 'These credentials do not match our records.', | |||||
| 'password' => 'The provided password is incorrect.', | |||||
| 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', | |||||
| ]; | |||||
| @@ -0,0 +1,19 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Pagination Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are used by the paginator library to build | |||||
| | the simple pagination links. You are free to change them to anything | |||||
| | you want to customize your views to better match your application. | |||||
| | | |||||
| */ | |||||
| 'previous' => '« Previous', | |||||
| 'next' => 'Next »', | |||||
| ]; | |||||
| @@ -0,0 +1,22 @@ | |||||
| <?php | |||||
| return [ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Password Reset Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines are the default lines which match reasons | |||||
| | that are given by the password broker for a password update attempt | |||||
| | has failed, such as for an invalid token or invalid new password. | |||||
| | | |||||
| */ | |||||
| 'reset' => '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.", | |||||
| ]; | |||||
| @@ -0,0 +1,205 @@ | |||||
| <?php | |||||
| return array_merge([ | |||||
| /* | |||||
| |-------------------------------------------------------------------------- | |||||
| | Validation Language Lines | |||||
| |-------------------------------------------------------------------------- | |||||
| | | |||||
| | The following language lines contain the default error messages used by | |||||
| | the validator class. Some of these rules have multiple versions such | |||||
| | as the size rules. Feel free to tweak each of these messages here. | |||||
| | | |||||
| */ | |||||
| 'accepted' => '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' => 'すでに使われています', | |||||
| ]); | |||||
| @@ -23,9 +23,28 @@ RouteHelper::get('/qr-service/get-ticket', App\Http\Controllers\Web\QRService\Cr | |||||
| Route::middleware('auth:sanctum')->group(function () { | Route::middleware('auth:sanctum')->group(function () { | ||||
| // 管理者ルート | |||||
| Route::middleware(RouteHelper::role([UserRole::ADMIN]))->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 () { | Route::middleware(RouteHelper::role([UserRole::ADMIN, UserRole::CUSTOMER]))->group(function () { | ||||
| RouteHelper::post('/role/switch', App\Http\Controllers\Web\Auth\SwitchController::class); | RouteHelper::post('/role/switch', App\Http\Controllers\Web\Auth\SwitchController::class); | ||||
| RouteHelper::get('/role/switch/end', App\Http\Controllers\Web\Auth\SwitchEndController::class); | RouteHelper::get('/role/switch/end', App\Http\Controllers\Web\Auth\SwitchEndController::class); | ||||