diff --git a/app/Http/Controllers/Admin/OpeController.php b/app/Http/Controllers/Admin/OpeController.php index 0637078..d1e6c88 100644 --- a/app/Http/Controllers/Admin/OpeController.php +++ b/app/Http/Controllers/Admin/OpeController.php @@ -18,7 +18,7 @@ class OpeController extends Controller $inputs = [ 'isMethodPost' => $request->isMethod('post'), 'sort' => $request->input('sort', 'ope_id'), - 'sort_type' => $request->input('sort_type', 'desc'), + 'sort_type' => $request->input('sort_type', 'asc'), 'isExport' => false, ]; @@ -37,17 +37,17 @@ class OpeController extends Controller public function add(Request $request) { if ($request->isMethod('get')) { - // add.blade.php は include する _form が期待する変数名を使う + return view('admin.opes.add', [ - 'isEdit' => 0, - 'isInfo' => 0, - // 初期値(存在しなくてもOKだが、Notice 防止のために入れておく) + + 'isEdit' => false, + 'record' => new Ope(), 'ope_id' => null, 'ope_name' => '', 'ope_type' => '', 'ope_mail' => '', 'ope_phone'=> '', - // 以下はフォームで参照される可能性のあるキーを空で用意 + 'ope_sendalart_que1' => 0, 'ope_sendalart_que2' => 0, 'ope_sendalart_que3' => 0, 'ope_sendalart_que4' => 0, 'ope_sendalart_que5' => 0, 'ope_sendalart_que6' => 0, 'ope_sendalart_que7' => 0, 'ope_sendalart_que8' => 0, 'ope_sendalart_que9' => 0, @@ -58,21 +58,46 @@ class OpeController extends Controller ]); } + // 入力値を一旦取得 + $data = $request->all(); + + // --- バリデーション --- $rules = [ + 'login_id' => 'required|string|max:255|unique:ope,login_id', 'ope_name' => 'required|string|max:255', 'ope_type' => 'required|string|max:50', - 'ope_mail' => 'nullable|email|max:255', + 'ope_mail' => [ + 'required', + function ($attribute, $value, $fail) { + // ; でも , でもOK、保存時は ; に統一 + $emails = array_map('trim', explode(';', str_replace(',', ';', $value))); + foreach ($emails as $email) { + if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) { + $fail("無効なメールアドレス形式です: {$email}"); + } + } + } + ], 'ope_phone' => 'nullable|string|max:50', + 'password' => 'required|string|min:8|confirmed', ]; - $this->validate($request, $rules); + $request->validate($rules); + + // --- 保存用にメールを ; 区切りに統一 --- + $emails = array_filter(array_map('trim', explode(';', str_replace(',', ';', $data['ope_mail'])))); + $data['ope_mail'] = implode(';', $emails); + + // 保存処理 $ope = new Ope(); - $ope->fill($request->only($ope->getFillable())); + $ope->fill($data); $ope->save(); - return redirect()->route('opes')->with('success', 'オペレータを登録しました。'); + return redirect()->route('opes')->with('success', '登録しました。'); } + + /** * 編集(GET 画面 / POST 更新) */ @@ -82,63 +107,76 @@ class OpeController extends Controller if (!$ope) abort(404); if ($request->isMethod('get')) { - // edit.blade.php が参照する変数名に合わせて渡す - return view('admin.opes.edit', array_merge( - [ - 'isEdit' => 1, - 'isInfo' => 0, - 'ope_id' => $ope->ope_id, - ], - $ope->toArray() - )); + return view('admin.opes.edit', [ + 'isEdit' => true, + 'record' => $ope, + ]); } + // 入力値を一旦取得 + $data = $request->all(); + + // --- バリデーション --- $rules = [ + 'login_id' => "required|string|max:255|unique:ope,login_id,{$id},ope_id", // 編集時は自分を除外 'ope_name' => 'required|string|max:255', 'ope_type' => 'required|string|max:50', - 'ope_mail' => 'nullable|email|max:255', 'ope_phone' => 'nullable|string|max:50', + 'ope_mail' => [ + 'required', + function ($attribute, $value, $fail) { + // , でも ; でもOKにする + $emails = array_map('trim', explode(';', str_replace(',', ';', $value))); + foreach ($emails as $email) { + if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) { + $fail("無効なメールアドレス形式です: {$email}"); + } + } + } + ], + 'password' => 'nullable|string|min:8|confirmed', // 編集時は任意 ]; - $this->validate($request, $rules); - $ope->fill($request->only($ope->getFillable())); + $request->validate($rules); + + // --- 保存用にメールを ; 区切りに統一 --- + if (!empty($data['ope_mail'])) { + $emails = array_filter(array_map('trim', explode(';', str_replace(',', ';', $data['ope_mail'])))); + $data['ope_mail'] = implode(';', $emails); + } + + // パスワード空なら更新しない + if (empty($data['password'])) { + unset($data['password']); + } + + // 保存処理 + $ope->fill($data); $ope->save(); - return redirect()->route('opes')->with('success', 'オペレータを更新しました。'); + return redirect()->route('opes')->with('success', '更新しました。'); } - /** - * 詳細 - */ - public function info($id) - { - $ope = Ope::getByPk($id); - if (!$ope) abort(404); - - // info.blade.php が参照する変数に合わせてセット - return view('admin.opes.info', array_merge( - [ - 'isEdit' => 0, - 'isInfo' => 1, - 'ope_id' => $ope->ope_id, - ], - $ope->toArray() - )); - } /** - * 削除(単体 / 複数) + * 削除(単体 or 複数) */ + public function delete(Request $request) { $ids = []; + + // 単体削除 if ($request->filled('id')) { $ids[] = (int) $request->input('id'); } - if ($request->filled('ids') && is_array($request->input('ids'))) { - $ids = array_merge($ids, array_map('intval', $request->input('ids'))); + + // 複数削除 + if ($request->filled('ids')) { + $ids = array_merge($ids, array_map('intval', (array)$request->input('ids'))); } - $ids = array_values(array_unique($ids)); + + $ids = array_unique($ids); if (!$ids) { return back()->with('error', '削除対象が選択されていません。'); diff --git a/app/Http/Controllers/Admin/TaxController.php b/app/Http/Controllers/Admin/TaxController.php index 5880c53..a4449d0 100644 --- a/app/Http/Controllers/Admin/TaxController.php +++ b/app/Http/Controllers/Admin/TaxController.php @@ -21,7 +21,6 @@ class TaxController extends Controller // 絞り込み $keyword = trim((string) $request->input('kw')); if ($keyword !== '') { - // 数値型でも互換のため部分一致を残す $query->where('tax_percent', 'like', "%{$keyword}%"); } $from = $request->input('from'); @@ -33,15 +32,15 @@ class TaxController extends Controller $query->whereDate('tax_day', '<=', $to); } - // ソート(既定:適用日 降順) - $sort = $request->input('sort', 'tax_day'); - $type = strtolower($request->input('sort_type', 'desc')); + // ソート(既定:ID 昇順) + $sort = $request->input('sort', 'tax_id'); + $type = strtolower($request->input('sort_type', 'asc')); $allow = ['tax_day', 'tax_percent', 'updated_at', 'created_at', 'tax_id']; if (!in_array($sort, $allow, true)) { - $sort = 'tax_day'; + $sort = 'tax_id'; } if (!in_array($type, ['asc', 'desc'], true)) { - $type = 'desc'; + $type = 'asc'; } $query->orderBy($sort, $type); @@ -57,12 +56,13 @@ class TaxController extends Controller ]); } + public function add(Request $request) { if ($request->isMethod('post')) { $data = $request->validate([ 'tax_percent' => ['required', 'numeric', 'min:0', 'max:1000'], - 'tax_day' => ['required', 'date', 'unique:tax,tax_day'], + 'tax_day' => ['required', 'date'], ]); $data['operator_id'] = optional(\Auth::user())->ope_id ?? null; $data['tax_percent'] = number_format((float)$data['tax_percent'], 2, '.', ''); @@ -85,7 +85,7 @@ class TaxController extends Controller if ($request->isMethod('post')) { $data = $request->validate([ 'tax_percent' => ['required', 'numeric', 'min:0', 'max:1000'], - 'tax_day' => ['required', 'date', 'unique:tax,tax_day,' . $tax->tax_id . ',tax_id'], + 'tax_day' => ['required', 'date'], ]); $data['operator_id'] = optional(\Auth::user())->ope_id ?? null; $data['tax_percent'] = number_format((float)$data['tax_percent'], 2, '.', ''); diff --git a/app/Models/Ope.php b/app/Models/Ope.php index a94327a..2c48b05 100644 --- a/app/Models/Ope.php +++ b/app/Models/Ope.php @@ -33,29 +33,31 @@ class Ope extends Authenticatable */ protected $fillable = [ '//TODO オペレータID not found in database specs', - 'ope_name', // オペレータ名 - 'ope_type', // オペレータ種別 - 'ope_mail', // メールアドレス - 'ope_phone', // 電話番号 - 'ope_sendalart_que1', // キュー1アラート送信 - 'ope_sendalart_que2', // キュー2アラート送信 - 'ope_sendalart_que3', // キュー3アラート送信 - 'ope_sendalart_que4', // キュー4アラート送信 - 'ope_sendalart_que5', // キュー5アラート送信 - 'ope_sendalart_que6', // キュー6アラート送信 - 'ope_sendalart_que7', // キュー7アラート送信 - 'ope_sendalart_que8', // キュー8アラート送信 - 'ope_sendalart_que9', // キュー9アラート送信 - 'ope_sendalart_que10', // キュー10アラート送信 - 'ope_sendalart_que11', // キュー11アラート送信 - 'ope_sendalart_que12', // キュー12アラート送信 - 'ope_sendalart_que13', // キュー13アラート送信 - 'ope_auth1', // 権限1 - 'ope_auth2', // 権限2 - 'ope_auth3', // 権限3 - 'ope_auth4', // 権限4 - 'ope_quit_flag', // 退職フラグ - 'ope_quitday' // 退職日 + 'login_id', // ログインID + 'password', // パスワード + 'ope_name', // オペレータ名 + 'ope_type', // オペレータ種別 + 'ope_mail', // メールアドレス(複数可) + 'ope_phone', // 電話番号 + 'ope_sendalart_que1', + 'ope_sendalart_que2', + 'ope_sendalart_que3', + 'ope_sendalart_que4', + 'ope_sendalart_que5', + 'ope_sendalart_que6', + 'ope_sendalart_que7', + 'ope_sendalart_que8', + 'ope_sendalart_que9', + 'ope_sendalart_que10', + 'ope_sendalart_que11', + 'ope_sendalart_que12', + 'ope_sendalart_que13', + 'ope_auth1', + 'ope_auth2', + 'ope_auth3', + 'ope_auth4', + 'ope_quit_flag', + 'ope_quitday', ]; /** @@ -124,7 +126,7 @@ class Ope extends Authenticatable // POST検索条件の処理 if ($inputs['isMethodPost']) { - // 検索条件があればここに追加 + } // ソート処理 @@ -136,12 +138,14 @@ class Ope extends Authenticatable if ($inputs['isExport']) { $list = $list->get(); } else { - $list = $list->paginate(\App\Utils::item_per_page); + // ページネーション件数を20に固定 + $list = $list->paginate(20); } return $list; } + /** * プライマリキーでオペレータを取得 * diff --git a/resources/lang/ja/validation.php b/resources/lang/ja/validation.php index a98133a..35db3b8 100644 --- a/resources/lang/ja/validation.php +++ b/resources/lang/ja/validation.php @@ -257,6 +257,10 @@ return [ // SWA-59 'ope_id' => 'オペレータID', // 'ope_id' => 'オペレータ名', + 'ope_belong' => 'オペレータ所属名', + 'login_id' => 'ログインID', + 'ope_pass' => 'パスワード', + 'ope_pass_confirmation' => 'パスワード確認', 'ope_name' => 'オペレータ名', 'ope_type' => 'オペレータ種別', 'ope_mail' => 'メールアドレス', @@ -399,5 +403,6 @@ return [ 'payment_companyname' => '事業者名', + ], ]; diff --git a/resources/views/admin/managers/_form.blade.php b/resources/views/admin/managers/_form.blade.php index dbce158..8f3aa44 100644 --- a/resources/views/admin/managers/_form.blade.php +++ b/resources/views/admin/managers/_form.blade.php @@ -6,13 +6,13 @@ @elseif(Session::has('error'))
-

{{ __('誤差') }}:

+

{{ __(' 入力内容に不備があります:') }}:

{!! Session::get('error') !!}
@elseif(isset($errorMsg))
-

{{ __('誤差') }}:

+

{{ __(' 入力内容に不備があります:') }}:

{!! $errorMsg !!}
@endif @@ -68,11 +68,11 @@ {{-- 所属駐輪場 --}}
- +
-
+ @if ($errors->any()) +
+

入力内容に不備があります:

+
    + @foreach ($errors->all() as $error) +
  1. {{ $error }}
  2. + @endforeach +
@endif - -
- -
-
-
- -
-
- +
+ {{-- オペレータID(編集時のみ表示) --}} + @if($isEdit) +
+ +
+
+ +
+ @endif - @if(!$isInfo) -
- + +
+ +
+
+
+ +
+
+ + + +
+ +
+
+
+ +
+
+ + + {{-- パスワード(新規必須 / 編集任意) --}} +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ + + +
+ +
+
+
+ +
+
+ + + +
+ +
+
+ +
+ + + +
+ +
+
+ +
+ + + {{-- ▼ キュー1〜13アラート送信 --}} + @for ($i = 1; $i <= 13; $i++) +
+ +
+
+
+
+ {'ope_sendalart_que'.$i} : 0) == 1 ? 'checked' : '' }}> +
-
-
- -
+
+ {'ope_sendalart_que'.$i} : 0) == 0 ? 'checked' : '' }}> +
-
- +
+
+ @endfor + {{-- ▲ キュー1〜13 --}} + + +
+ +
+
+
+
+ ope_auth1 : '付与しない') == '管理者権限付与' ? 'checked' : '' }}> +
-
-
- -
+
+ ope_auth1 : '付与しない') == '付与しない' ? 'checked' : '' }}> +
+
+
+ + +
+ +
+
+
+
+ ope_auth2 : '付与しない') == 'エリアマネージャー権限付与' ? 'checked' : '' }}> + +
+
+ ope_auth2 : '付与しない') == '付与しない' ? 'checked' : '' }}> + +
+
+
+ + +
+ +
+
+
+
+ ope_auth3 : '付与しない') == 'エリアオペレーター権限付与' ? 'checked' : '' }}> + +
+
+ ope_auth3 : '付与しない') == '付与しない' ? 'checked' : '' }}> + +
+
+
+ + +
+ +
+
+
+
+ ope_auth4 : '付与しない') == 'オペレーター権限付与' ? 'checked' : '' }}> + +
+
+ ope_auth4 : '付与しない') == '付与しない' ? 'checked' : '' }}> + +
+
+
+ + +
+ +
+
+
+
+ ope_quit_flag : 0) == 1 ? 'checked' : '' }}> + +
+
+ ope_quit_flag : 0) == 0 ? 'checked' : '' }}> + +
+
+
+ + + +
+ +
+
+ +
+ + + +
+ {{-- ▼ 下部ボタン --}} +
+
+ + {{-- 登録ボタン --}} + @if($isEdit) + + @else + @endif - -
- -
-
-
- - -
-
- - - -
- -
-
-
- -
-
- - - -
- -
-
-
- -
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - -
- -
-
-
-
- - -
-
- - -
-
-
- - - -
- -
-
-
- -
-
- + {{-- 削除ボタン(編集時のみ表示) --}} + @if($isEdit) + + @endif
- {{-- 下部ボタン --}} - @if($isEdit) - - - @else - - - @endif +
+
diff --git a/resources/views/admin/opes/add.blade.php b/resources/views/admin/opes/add.blade.php index cb1aa0e..cc22b13 100644 --- a/resources/views/admin/opes/add.blade.php +++ b/resources/views/admin/opes/add.blade.php @@ -1,43 +1,44 @@ @extends('layouts.app') -@section('title', '[東京都|〇〇駐輪場] オペレータマスタ') +@section('title', '新規') @section('content') - -
-
-
-
-

新規登録

-
-
- -
-
-
+ +
+
+
+
+

新規

+
+ +
+ +
+
- - - -
-
- -
-
-
-
+
+ +
+
+
+
+
+
+ @csrf - @include('admin.opes._form', ['isEdit' => 0, 'isInfo' => 0]) + @include('admin.opes._form', ['isEdit' => false])
-
-
- +
+
@endsection diff --git a/resources/views/admin/opes/edit.blade.php b/resources/views/admin/opes/edit.blade.php index 208a4b2..7cee8d1 100644 --- a/resources/views/admin/opes/edit.blade.php +++ b/resources/views/admin/opes/edit.blade.php @@ -1,48 +1,55 @@ @extends('layouts.app') -@section('title', '[東京都|〇〇駐輪場] オペレータマスタ') +@section('title', '編集') @section('content') - + {{-- Content Header --}}

編集

-
+
+ -
-
+
+
+
- - + {{-- Main Content --}}
-
-
+ {{-- Edit Form --}} + @csrf - @include('admin.opes._form', ['isEdit' => 1, 'isInfo' => 0]) + @include('admin.opes._form', ['isEdit' => true]) +
+ + {{-- Delete Form --}} +
- -
- @endsection diff --git a/resources/views/admin/opes/info.blade.php b/resources/views/admin/opes/info.blade.php deleted file mode 100644 index df6ef99..0000000 --- a/resources/views/admin/opes/info.blade.php +++ /dev/null @@ -1,48 +0,0 @@ -@extends('layouts.app') -@section('title', '[東京都|〇〇駐輪場] オペレータマスタ') - -@section('content') - -
-
-
-
-

[東京都|〇〇駐輪場] オペレータマスタ

-
-
- -
-
-
-
- - - -
-
- -
-
-
-
- @csrf - @include('admin.opes._form', ['isEdit' => 0, 'isInfo' => 1]) -
-
-
-
- - -
-
- -@endsection diff --git a/resources/views/admin/opes/list.blade.php b/resources/views/admin/opes/list.blade.php index 931bc70..773dab0 100644 --- a/resources/views/admin/opes/list.blade.php +++ b/resources/views/admin/opes/list.blade.php @@ -1,5 +1,5 @@ @extends('layouts.app') -@section('title', '[東京都|〇〇駐輪場] オペレータマスタ') +@section('title', 'オペレータマスタ') @section('content')
@@ -32,8 +32,7 @@
- - +
{{ $list->appends(['sort' => $sort, 'sort_type' => $sort_type])->links('pagination') }}
@@ -49,13 +48,13 @@ @elseif(Session::has('error'))
-

エラー:

+

入力内容に不備があります。

{!! Session::get('error') !!}
@elseif(isset($errorMsg))
-

エラー:

+

入力内容に不備があります。

{!! $errorMsg !!}
@endif @@ -70,19 +69,21 @@ - + オペレータID オペレータ名 - パスワード + オペレータ種別 メールアドレス 電話番号 - キュー1~13アラート送信 - 管理者権限 - エリアマネージャー - エリアオペレーター - オペレーター権限 + @for ($i = 1; $i <= 13; $i++) + キュー{{ $i }}アラート送信 + @endfor + 管理者権限付与 + エリアマネージャー権限付与 + エリアオペレーター権限付与 + オペレーター権限付与 退職フラグ 退職日 @@ -92,31 +93,21 @@
- + 編集
{{ $item->ope_id }} {{ $item->ope_name }} - {{ $item->ope_pass }} + {{ \App\Models\Ope::OPE_TYPE[$item->ope_type] }} {{ $item->ope_mail }} {{ $item->ope_phone }} - - {{ $item->ope_sendalart_que1 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que2 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que3 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que4 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que5 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que6 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que7 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que8 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que9 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que10 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que11 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que12 ? 'はい' : 'いいえ' }} / - {{ $item->ope_sendalart_que13 ? 'はい' : 'いいえ' }} - + @for ($i = 1; $i <= 13; $i++) + + {{ $item->{'ope_sendalart_que'.$i} ? 'はい' : 'いいえ' }} + + @endfor {{ $item->ope_auth1 }} {{ $item->ope_auth2 }} {{ $item->ope_auth3 }} @@ -134,43 +125,5 @@
-
-@push('scripts') - -@endpush @endsection diff --git a/resources/views/admin/tax/_form.blade.php b/resources/views/admin/tax/_form.blade.php index 52e314e..4016b5b 100644 --- a/resources/views/admin/tax/_form.blade.php +++ b/resources/views/admin/tax/_form.blade.php @@ -51,12 +51,13 @@ inputmode="decimal" pattern="^\d+(\.\d{1,2})?$" class="form-control text-end" - value="{{ old('tax_percent', is_numeric($tax->tax_percent ?? null) ? rtrim(rtrim($tax->tax_percent, '0'), '.') : '') }}" + value="{{ old('tax_percent', isset($tax->tax_percent) ? rtrim(rtrim($tax->tax_percent, '0'), '.') : '') }}" placeholder="消費税率">
+ {{-- 適用日(必須・日付型) --}}