diff --git a/app/Http/Controllers/Admin/CityController.php b/app/Http/Controllers/Admin/CityController.php index ea8cea3..88e66c8 100644 --- a/app/Http/Controllers/Admin/CityController.php +++ b/app/Http/Controllers/Admin/CityController.php @@ -49,9 +49,21 @@ class CityController extends Controller if ($request->isMethod('POST')) { $rules = [ - 'city_name' => 'required|string|max:255', + 'city_name' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], // 全角のみ + 'print_layout' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], // 全角のみ + 'city_user' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], // 全角のみ + 'city_remarks' => ['nullable', 'string', 'max:20'], // 全角半角可・任意 ]; - $validator = Validator::make($request->all(), $rules); + $messages = [ + 'city_name.required' => '市区名は必須です。', + 'city_name.regex' => '市区名は全角で入力してください。', + 'print_layout.required' => '印字レイアウトファイルは必須です。', + 'print_layout.regex' => '印字レイアウトファイルは全角で入力してください。', + 'city_user.required' => '顧客M入力不要フィールドIDは必須です。', + 'city_user.regex' => '顧客M入力不要フィールドIDは全角で入力してください。', + 'city_remarks.max' => '備考は20文字以内で入力してください。', + ]; + $validator = Validator::make($request->all(), $rules, $messages); $inputs = array_merge($inputs, $request->all()); @@ -91,9 +103,21 @@ class CityController extends Controller if ($request->isMethod('POST')) { $rules = [ - 'city_name' => 'required|string|max:255', + 'city_name' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], + 'print_layout' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], + 'city_user' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'], + 'city_remarks' => ['nullable', 'string', 'max:20'], ]; - $validator = Validator::make($request->all(), $rules); + $messages = [ + 'city_name.required' => '市区名は必須です。', + 'city_name.regex' => '市区名は全角で入力してください。', + 'print_layout.required' => '印字レイアウトファイルは必須です。', + 'print_layout.regex' => '印字レイアウトファイルは全角で入力してください。', + 'city_user.required' => '顧客M入力不要フィールドIDは必須です。', + 'city_user.regex' => '顧客M入力不要フィールドIDは全角で入力してください。', + 'city_remarks.max' => '備考は20文字以内で入力してください。', + ]; + $validator = Validator::make($request->all(), $rules, $messages); if (!$validator->fails()) { $city->fill($request->only([ @@ -130,7 +154,10 @@ class CityController extends Controller public function delete(Request $request) { $arr_pk = $request->get('pk'); - if ($arr_pk && City::destroy($arr_pk)) { + if (!$arr_pk) { + return redirect()->route('city')->with('error', __('削除する市区を選択してください。')); + } + if (City::destroy($arr_pk)) { return redirect()->route('city')->with('success', __("削除が完了しました。")); } else { return redirect()->route('city')->with('error', __('削除に失敗しました。')); diff --git a/resources/views/admin/CityMaster/_form.blade.php b/resources/views/admin/CityMaster/_form.blade.php index 05e9cae..fbcb27f 100644 --- a/resources/views/admin/CityMaster/_form.blade.php +++ b/resources/views/admin/CityMaster/_form.blade.php @@ -4,21 +4,21 @@
- - + +
- - + +
- - + +
- +
diff --git a/resources/views/admin/CityMaster/add.blade.php b/resources/views/admin/CityMaster/add.blade.php index e362958..6c1f08d 100644 --- a/resources/views/admin/CityMaster/add.blade.php +++ b/resources/views/admin/CityMaster/add.blade.php @@ -1,43 +1,27 @@ @extends('layouts.app') -@section('title', '[東京都|〇〇駐輪場] マスタ管理') - @section('content') - -
-
-
-
-

[東京都|〇〇駐輪場] マスタ管理

-
-
- -
-
-
+ +
+
+

新規登録

+
- - -
-

市区マスタ 新規登録

- -
-
-
- @csrf - @include('admin.CityMaster._form', ['isEdit' => 0, 'isInfo' => 0]) -
- - 戻る -
-
+
+
+
+ @csrf + @include('admin.CityMaster._form', ['isEdit' => 0, 'isInfo' => 0]) +
+ + 戻る +
+
+
-
-@endsection +@endsection \ No newline at end of file diff --git a/resources/views/admin/CityMaster/edit.blade.php b/resources/views/admin/CityMaster/edit.blade.php index 6b86c8c..c8581fb 100644 --- a/resources/views/admin/CityMaster/edit.blade.php +++ b/resources/views/admin/CityMaster/edit.blade.php @@ -3,31 +3,18 @@ @section('title', '市区マスタ編集') @section('content') - -
-
-
-
-

[東京都|〇〇駐輪場] 市区マスタ

-
-
- -
-
-
-
- -
-

市区マスタ 編集

- +
+

編集

+ +
+ @includeIf('common.flash')
diff --git a/resources/views/admin/CityMaster/list.blade.php b/resources/views/admin/CityMaster/list.blade.php index 9b76039..16da785 100644 --- a/resources/views/admin/CityMaster/list.blade.php +++ b/resources/views/admin/CityMaster/list.blade.php @@ -3,6 +3,14 @@ @section('title', '市区マスタ') @section('content') + {{-- ▼ フラッシュメッセージ --}} + @if(session('success')) +
{{ session('success') }}
+ @endif + @if(session('error')) +
{{ session('error') }}
+ @endif +
@@ -40,10 +48,8 @@ - - + 市区ID @if($sort === 'city_id') @@ -51,8 +57,7 @@ - + 市区名 @if($sort === 'city_name') @@ -69,15 +74,13 @@ - 編集 + 編集 {{ $city->city_id }} {{ $city->city_name }} {{ $city->print_layout }} {{ $city->city_user }} {{ $city->city_remarks }} -   @endforeach