This commit is contained in:
parent
b13e91d592
commit
57199fe92b
@ -14,7 +14,7 @@ class CityController extends Controller
|
|||||||
{
|
{
|
||||||
$sort = $request->input('sort', 'city_id');
|
$sort = $request->input('sort', 'city_id');
|
||||||
$sortType = $request->input('sort_type', 'asc');
|
$sortType = $request->input('sort_type', 'asc');
|
||||||
$page = $request->get('page', 1);
|
$page = (int)$request->get('page', 1);
|
||||||
|
|
||||||
$menuAccessService = app(\App\Services\MenuAccessService::class);
|
$menuAccessService = app(\App\Services\MenuAccessService::class);
|
||||||
|
|
||||||
@ -31,12 +31,11 @@ class CityController extends Controller
|
|||||||
$query->where('city_name', 'like', '%' . $request->input('city_name') . '%');
|
$query->where('city_name', 'like', '%' . $request->input('city_name') . '%');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ソート処理
|
|
||||||
if (!empty($sort)) {
|
if (!empty($sort)) {
|
||||||
$query->orderBy($sort, $sortType);
|
$query->orderBy($sort, $sortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $query->paginate(20);
|
$list = $query->paginate(50);
|
||||||
|
|
||||||
// インデックス超過処理
|
// インデックス超過処理
|
||||||
if ($list->total() > 0 && $page > $list->lastPage()) {
|
if ($list->total() > 0 && $page > $list->lastPage()) {
|
||||||
@ -46,8 +45,7 @@ class CityController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('admin.CityMaster.list', [
|
return view('admin.cities.list', [
|
||||||
'isMethodPost' => $request->isMethod('post'),
|
|
||||||
'sort' => $sort,
|
'sort' => $sort,
|
||||||
'sort_type' => $sortType,
|
'sort_type' => $sortType,
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
@ -55,123 +53,102 @@ class CityController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 新規画面 */
|
||||||
public function add(Request $request)
|
public function add(Request $request)
|
||||||
{
|
{
|
||||||
$inputs = [
|
$record = new City();
|
||||||
'city_name' => '',
|
|
||||||
'print_layout' => '',
|
|
||||||
'city_user' => '',
|
|
||||||
'city_remarks' => '',
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
return view('admin.cities.add', [
|
||||||
$rules = [
|
'record' => $record,
|
||||||
'city_name' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'],
|
'errorMsg' => [],
|
||||||
'print_layout' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'],
|
|
||||||
'city_user' => ['required', 'string', 'max:10', 'regex:/^[^ -~。-゚]+$/u'],
|
|
||||||
'city_remarks' => ['nullable', 'string', 'max:20'],
|
|
||||||
];
|
|
||||||
$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());
|
|
||||||
|
|
||||||
if (!$validator->fails()) {
|
|
||||||
$maxId = DB::table('city')->max('city_id');
|
|
||||||
$newCityId = $maxId ? $maxId + 1 : 1;
|
|
||||||
|
|
||||||
$city = new City();
|
|
||||||
$city->city_id = $newCityId;
|
|
||||||
$city->fill($request->only([
|
|
||||||
'city_name',
|
|
||||||
'print_layout',
|
|
||||||
'city_user',
|
|
||||||
'city_remarks',
|
|
||||||
]));
|
|
||||||
|
|
||||||
if ($city->save()) {
|
|
||||||
$request->session()->flash('success', __('登録に成功しました'));
|
|
||||||
return redirect()->route('city');
|
|
||||||
} else {
|
|
||||||
$request->session()->flash('error', __('登録に失敗しました'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$inputs['errorMsg'] = $validator->errors()->all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.CityMaster.add', $inputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function edit(Request $request, $pk, $view = '')
|
|
||||||
{
|
|
||||||
$city = City::find($pk);
|
|
||||||
if (!$city) {
|
|
||||||
abort(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
// メニューアクセス制御確認
|
|
||||||
$menuAccessService = app(\App\Services\MenuAccessService::class);
|
|
||||||
if (!$menuAccessService->canAccessCity($city->city_id)) {
|
|
||||||
abort(403, 'この自治体へのアクセス権限がありません。');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->isMethod('POST')) {
|
|
||||||
$rules = [
|
|
||||||
'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'],
|
|
||||||
];
|
|
||||||
$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([
|
|
||||||
'city_name',
|
|
||||||
'print_layout',
|
|
||||||
'city_user',
|
|
||||||
'city_remarks',
|
|
||||||
]));
|
|
||||||
|
|
||||||
if ($city->save()) {
|
|
||||||
$request->session()->flash('success', __('更新に成功しました'));
|
|
||||||
return redirect()->route('city');
|
|
||||||
} else {
|
|
||||||
$request->session()->flash('error', __('更新に失敗しました'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return view('admin.CityMaster.edit', [
|
|
||||||
'city' => $city,
|
|
||||||
'errorMsg' => $validator->errors()->all(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return view($view ?: 'admin.CityMaster.edit', [
|
|
||||||
'city' => $city,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function info(Request $request, $pk)
|
/** 登録 */
|
||||||
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
return $this->edit($request, $pk, 'CityMaster.info');
|
[$rules, $messages] = $this->rulesAndMessages();
|
||||||
|
$validator = Validator::make($request->all(), $rules, $messages);
|
||||||
|
|
||||||
|
$record = new City();
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
|
||||||
|
$record->fill($request->only(['city_name', 'print_layout', 'city_remarks']));
|
||||||
|
|
||||||
|
return view('admin.cities.add', [
|
||||||
|
'record' => $record,
|
||||||
|
'errorMsg' => $validator->errors()->all(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$maxId = DB::table('city')->max('city_id');
|
||||||
|
$newCityId = $maxId ? $maxId + 1 : 1;
|
||||||
|
|
||||||
|
$record->city_id = $newCityId;
|
||||||
|
$record->fill($request->only([
|
||||||
|
'city_name',
|
||||||
|
'print_layout',
|
||||||
|
'city_remarks',
|
||||||
|
]));
|
||||||
|
|
||||||
|
if ($record->save()) {
|
||||||
|
return redirect()->route('city')->with('success', __('登録に成功しました'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->withInput()->with('error', __('登録に失敗しました'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 編集画面 */
|
||||||
|
public function edit(Request $request, $id)
|
||||||
|
{
|
||||||
|
$record = City::find($id);
|
||||||
|
if (!$record) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->authorizeCityAccess($record);
|
||||||
|
|
||||||
|
return view('admin.cities.edit', [
|
||||||
|
'record' => $record,
|
||||||
|
'errorMsg' => [],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新 */
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$record = City::find($id);
|
||||||
|
if (!$record) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->authorizeCityAccess($record);
|
||||||
|
|
||||||
|
[$rules, $messages] = $this->rulesAndMessages();
|
||||||
|
$validator = Validator::make($request->all(), $rules, $messages);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
// 画面に戻る時に入力を保持
|
||||||
|
$record->fill($request->only(['city_name', 'print_layout', 'city_remarks']));
|
||||||
|
|
||||||
|
return view('admin.cities.edit', [
|
||||||
|
'record' => $record,
|
||||||
|
'errorMsg' => $validator->errors()->all(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->fill($request->only([
|
||||||
|
'city_name',
|
||||||
|
'print_layout',
|
||||||
|
'city_remarks',
|
||||||
|
]));
|
||||||
|
|
||||||
|
if ($record->save()) {
|
||||||
|
return redirect()->route('city')->with('success', __('更新に成功しました'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->withInput()->with('error', __('更新に失敗しました'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(Request $request)
|
public function delete(Request $request)
|
||||||
@ -180,15 +157,66 @@ class CityController extends Controller
|
|||||||
if (!$arr_pk) {
|
if (!$arr_pk) {
|
||||||
return redirect()->route('city')->with('error', __('削除する市区を選択してください。'));
|
return redirect()->route('city')->with('error', __('削除する市区を選択してください。'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (City::destroy($arr_pk)) {
|
if (City::destroy($arr_pk)) {
|
||||||
return redirect()->route('city')->with('success', __("削除が完了しました。"));
|
return redirect()->route('city')->with('success', __("削除が完了しました。"));
|
||||||
} else {
|
}
|
||||||
return redirect()->route('city')->with('error', __('削除に失敗しました。'));
|
|
||||||
|
return redirect()->route('city')->with('error', __('削除に失敗しました。'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function rulesAndMessages(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
// 市区名:全角 / 必須 / 最大20文字
|
||||||
|
'city_name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:20',
|
||||||
|
'regex:/^[^ -~。-゚]+$/u',
|
||||||
|
],
|
||||||
|
|
||||||
|
// 印字レイアウトファイル:半角英数字 / 必須 / 最大255文字
|
||||||
|
'print_layout' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
'regex:/^[A-Za-z0-9]+$/',
|
||||||
|
],
|
||||||
|
|
||||||
|
// 備考:任意 / 最大255文字
|
||||||
|
'city_remarks' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$messages = [
|
||||||
|
'city_name.required' => '市区名は必須です。',
|
||||||
|
'city_name.regex' => '市区名は全角文字で入力してください。',
|
||||||
|
'city_name.max' => '市区名は20文字以内で入力してください。',
|
||||||
|
|
||||||
|
'print_layout.required' => '印字レイアウトファイルは必須です。',
|
||||||
|
'print_layout.regex' => '印字レイアウトファイルは半角英数字で入力してください。',
|
||||||
|
'print_layout.max' => '印字レイアウトファイルは255文字以内で入力してください。',
|
||||||
|
|
||||||
|
'city_remarks.max' => '備考は255文字以内で入力してください。',
|
||||||
|
];
|
||||||
|
|
||||||
|
return [$rules, $messages];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function authorizeCityAccess(City $city): void
|
||||||
|
{
|
||||||
|
$menuAccessService = app(\App\Services\MenuAccessService::class);
|
||||||
|
if (!$menuAccessService->canAccessCity($city->city_id)) {
|
||||||
|
abort(403, 'この自治体へのアクセス権限がありません。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自治体ダッシュボード
|
* 自治体ダッシュボード(そのまま残すなら、別途 route 追加が必要)
|
||||||
*/
|
*/
|
||||||
public function dashboard(Request $request, $city_id)
|
public function dashboard(Request $request, $city_id)
|
||||||
{
|
{
|
||||||
@ -197,27 +225,22 @@ class CityController extends Controller
|
|||||||
return redirect()->route('city')->with('error', '指定された自治体が見つかりません。');
|
return redirect()->route('city')->with('error', '指定された自治体が見つかりません。');
|
||||||
}
|
}
|
||||||
|
|
||||||
// この自治体に関連する駐輪場データを取得
|
|
||||||
$parks = \App\Models\Park::where('city_id', $city_id)->get();
|
$parks = \App\Models\Park::where('city_id', $city_id)->get();
|
||||||
$parkIds = $parks->pluck('park_id')->toArray();
|
$parkIds = $parks->pluck('park_id')->toArray();
|
||||||
|
|
||||||
// この自治体の統計情報を取得
|
|
||||||
$contractsCount = 0;
|
$contractsCount = 0;
|
||||||
$usersCount = 0;
|
$usersCount = 0;
|
||||||
$waitingCount = 0;
|
$waitingCount = 0;
|
||||||
|
|
||||||
if (!empty($parkIds)) {
|
if (!empty($parkIds)) {
|
||||||
// 契約数を取得
|
|
||||||
$contractsCount = \App\Models\RegularContract::whereIn('park_id', $parkIds)->count();
|
$contractsCount = \App\Models\RegularContract::whereIn('park_id', $parkIds)->count();
|
||||||
|
|
||||||
// この自治体の駐輪場で契約しているユニークユーザー数を取得
|
|
||||||
$userIds = \App\Models\RegularContract::whereIn('park_id', $parkIds)
|
$userIds = \App\Models\RegularContract::whereIn('park_id', $parkIds)
|
||||||
->distinct()
|
->distinct()
|
||||||
->pluck('user_id')
|
->pluck('user_id')
|
||||||
->toArray();
|
->toArray();
|
||||||
$usersCount = count(array_filter($userIds));
|
$usersCount = count(array_filter($userIds));
|
||||||
|
|
||||||
// 予約待ち人数を取得(valid_flag = 1 かつ reserve_order が設定されているもの)
|
|
||||||
$waitingCount = DB::table('reserve')
|
$waitingCount = DB::table('reserve')
|
||||||
->whereIn('park_id', $parkIds)
|
->whereIn('park_id', $parkIds)
|
||||||
->where('valid_flag', 1)
|
->where('valid_flag', 1)
|
||||||
@ -225,7 +248,7 @@ class CityController extends Controller
|
|||||||
->where('reserve_order', '>', 0)
|
->where('reserve_order', '>', 0)
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
$stats = [
|
$stats = [
|
||||||
'parks_count' => $parks->count(),
|
'parks_count' => $parks->count(),
|
||||||
'contracts_count' => $contractsCount,
|
'contracts_count' => $contractsCount,
|
||||||
@ -235,4 +258,4 @@ class CityController extends Controller
|
|||||||
|
|
||||||
return view('admin.CityMaster.dashboard', compact('city', 'parks', 'stats'));
|
return view('admin.CityMaster.dashboard', compact('city', 'parks', 'stats'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{{-- アラート(任意エラー) --}}
|
{{-- アラート(任意エラー:旧互換) --}}
|
||||||
@if(isset($errorMsg))
|
@if(!empty($errorMsg))
|
||||||
<div class="alert alert-danger alert-dismissible" role="alert">
|
<div class="alert alert-danger alert-dismissible" role="alert">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
@if(is_array($errorMsg))
|
@if(is_array($errorMsg))
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<div class="alert alert-danger alert-dismissible">
|
<div class="alert alert-danger alert-dismissible">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}</h4>
|
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}</h4>
|
||||||
<ul>
|
<ul class="mb-0">
|
||||||
@foreach($errors->all() as $error)
|
@foreach($errors->all() as $error)
|
||||||
<li>{{ $error }}</li>
|
<li>{{ $error }}</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -55,7 +55,7 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
class="form-control form-control-lg bg-light"
|
class="form-control form-control-lg bg-light"
|
||||||
value="{{ old('city_id', $record->city_id ?? '') }}"
|
value="{{ $record->city_id ?? '' }}"
|
||||||
readonly>
|
readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -69,9 +69,10 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="city_name"
|
name="city_name"
|
||||||
class="form-control form-control-lg"
|
class="form-control form-control-lg @error('city_name') is-invalid @enderror"
|
||||||
placeholder="{{ __('市区名') }}"
|
placeholder="{{ __('市区名') }}"
|
||||||
value="{{ old('city_name', $record->city_name ?? ($city_name ?? '')) }}">
|
maxlength="20"
|
||||||
|
value="{{ old('city_name', $record->city_name ?? '') }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -83,9 +84,10 @@
|
|||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
name="print_layout"
|
name="print_layout"
|
||||||
class="form-control form-control-lg"
|
class="form-control form-control-lg @error('print_layout') is-invalid @enderror"
|
||||||
placeholder="{{ __('印字レイアウトファイル') }}"
|
placeholder="{{ __('印字レイアウトファイル') }}"
|
||||||
value="{{ old('print_layout', $record->print_layout ?? ($print_layout ?? '')) }}">
|
maxlength="255"
|
||||||
|
value="{{ old('print_layout', $record->print_layout ?? '') }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -95,10 +97,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-9">
|
<div class="form-group col-9">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<textarea class="form-control form-control-lg"
|
<textarea class="form-control form-control-lg @error('city_remarks') is-invalid @enderror"
|
||||||
rows="5"
|
rows="5"
|
||||||
placeholder="{{ __('備考') }}"
|
placeholder="{{ __('備考') }}"
|
||||||
name="city_remarks">{{ old('city_remarks', $record->city_remarks ?? ($city_remarks ?? '')) }}</textarea>
|
name="city_remarks"
|
||||||
|
maxlength="255">{{ old('city_remarks', $record->city_remarks ?? '') }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -110,11 +113,11 @@
|
|||||||
|
|
||||||
{{-- 登録/更新ボタン --}}
|
{{-- 登録/更新ボタン --}}
|
||||||
@if(!empty($isEdit))
|
@if(!empty($isEdit))
|
||||||
<button type="button" id="register_edit" class="btn btn-lg btn-success mr-2">
|
<button type="submit" class="btn btn-lg btn-success mr-2">
|
||||||
{{ __('登録') }}
|
{{ __('更新') }}
|
||||||
</button>
|
</button>
|
||||||
@else
|
@else
|
||||||
<button type="button" id="register" class="btn btn-lg btn-success mr-2 register">
|
<button type="submit" class="btn btn-lg btn-success mr-2">
|
||||||
{{ __('登録') }}
|
{{ __('登録') }}
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
@ -136,5 +139,4 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
<a href="{{ route('home') }}">ホーム</a>
|
<a href="{{ route('home') }}">ホーム</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item">
|
||||||
<a href="{{ route('cities.index') }}">市区マスタ</a>
|
<a href="{{ route('city') }}">市区マスタ</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="breadcrumb-item active">新規</li>
|
<li class="breadcrumb-item active">新規</li>
|
||||||
</ol>
|
</ol>
|
||||||
@ -35,12 +35,12 @@
|
|||||||
{{-- 新規登録フォーム --}}
|
{{-- 新規登録フォーム --}}
|
||||||
<form id="form_add"
|
<form id="form_add"
|
||||||
method="POST"
|
method="POST"
|
||||||
action="{{ route('cities.store') }}?back={{ urlencode(request()->get('back', request()->fullUrl())) }}"
|
action="{{ route('city.store', ['back' => request()->get('back', request()->fullUrl())]) }}"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
@include('admin.cities._form', [
|
@include('admin.cities._form', [
|
||||||
'isEdit' => false
|
'isEdit' => false,
|
||||||
])
|
])
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<ol class="breadcrumb float-sm-right text-sm">
|
<ol class="breadcrumb float-sm-right text-sm">
|
||||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item">
|
||||||
<a href="{{ route('cities.index') }}">市区マスタ</a>
|
<a href="{{ route('city') }}">市区マスタ</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="breadcrumb-item active">編集</li>
|
<li class="breadcrumb-item active">編集</li>
|
||||||
</ol>
|
</ol>
|
||||||
@ -33,24 +33,25 @@
|
|||||||
|
|
||||||
{{-- 編集フォーム --}}
|
{{-- 編集フォーム --}}
|
||||||
<form id="form_edit"
|
<form id="form_edit"
|
||||||
action="{{ route('cities.update', ['id' => $record->city_id]) }}?back={{ urlencode(request()->get('back', request()->fullUrl())) }}"
|
action="{{ route('city.update', ['id' => $record->city_id, 'back' => request()->get('back', request()->fullUrl())]) }}"
|
||||||
method="POST"
|
method="POST"
|
||||||
enctype="multipart/form-data">
|
enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
@include('admin.cities._form', [
|
@include('admin.cities._form', [
|
||||||
'isEdit' => true,
|
'isEdit' => true,
|
||||||
'record' => $record
|
|
||||||
])
|
])
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{{-- 削除フォーム(非表示) --}}
|
{{-- 削除フォーム(非表示) --}}
|
||||||
<form id="form_delete"
|
<form id="form_delete"
|
||||||
action="{{ route('cities.destroy') }}"
|
action="{{ route('city.delete') }}"
|
||||||
method="POST"
|
method="POST"
|
||||||
style="display:none;">
|
style="display:none;">
|
||||||
@csrf
|
@csrf
|
||||||
<input type="hidden" name="pk" value="{{ $record->city_id }}">
|
<input type="hidden" name="pk[]" value="{{ $record->city_id }}">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
|
||||||
{{-- 並び替え用 hidden --}}
|
{{-- 並び替え用 hidden --}}
|
||||||
<form method="GET" action="{{ route('cities.index') }}" id="list-form">
|
<form method="GET" action="{{ route('city') }}" id="list-form">
|
||||||
<input type="hidden" name="sort" id="sort" value="{{ $sort ?? '' }}">
|
<input type="hidden" name="sort" id="sort" value="{{ $sort ?? '' }}">
|
||||||
<input type="hidden" name="sort_type" id="sort_type" value="{{ $sort_type ?? '' }}">
|
<input type="hidden" name="sort_type" id="sort_type" value="{{ $sort_type ?? '' }}">
|
||||||
</form>
|
</form>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<div class="col-lg-12 mb-3 px-0">
|
<div class="col-lg-12 mb-3 px-0">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-sm btn-primary mr10"
|
class="btn btn-sm btn-primary mr10"
|
||||||
onclick="location.href='{{ route('cities.create') }}?back={{ urlencode(request()->fullUrl()) }}'">
|
onclick="location.href='{{ route('city.add', ['back' => request()->fullUrl()]) }}'">
|
||||||
新規
|
新規
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@ -74,10 +74,18 @@
|
|||||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
{!! Session::get('error') !!}
|
{!! Session::get('error') !!}
|
||||||
</div>
|
</div>
|
||||||
@elseif(isset($errorMsg))
|
@elseif(!empty($errorMsg))
|
||||||
<div class="alert alert-danger alert-dismissible">
|
<div class="alert alert-danger alert-dismissible">
|
||||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
{!! $errorMsg !!}
|
@if(is_array($errorMsg))
|
||||||
|
<ul class="mb-0">
|
||||||
|
@foreach($errorMsg as $msg)
|
||||||
|
<li>{{ $msg }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@else
|
||||||
|
{!! $errorMsg !!}
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@ -85,7 +93,7 @@
|
|||||||
{{-- ▼ テーブル --}}
|
{{-- ▼ テーブル --}}
|
||||||
<div class="col-lg-12 mb20 px-0">
|
<div class="col-lg-12 mb20 px-0">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<form id="form_delete" method="POST" action="{{ route('cities.destroy') }}">
|
<form id="form_delete" method="POST" action="{{ route('city.delete') }}">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<table class="table table-bordered dataTable text-nowrap">
|
<table class="table table-bordered dataTable text-nowrap">
|
||||||
@ -118,7 +126,7 @@
|
|||||||
<td style="background-color:#faebd7;">
|
<td style="background-color:#faebd7;">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<input type="checkbox" name="pk[]" value="{{ $city->city_id }}">
|
<input type="checkbox" name="pk[]" value="{{ $city->city_id }}">
|
||||||
<a href="{{ route('cities.edit', ['id' => $city->city_id]) }}?back={{ urlencode(request()->fullUrl()) }}"
|
<a href="{{ route('city.edit', ['id' => $city->city_id, 'back' => request()->fullUrl()]) }}"
|
||||||
class="btn btn-sm btn-outline-primary ml10">
|
class="btn btn-sm btn-outline-primary ml10">
|
||||||
編集
|
編集
|
||||||
</a>
|
</a>
|
||||||
@ -185,11 +185,17 @@ Route::middleware('auth')->group(function () {
|
|||||||
->middleware('check.city.access');
|
->middleware('check.city.access');
|
||||||
|
|
||||||
// 市区マスタ
|
// 市区マスタ
|
||||||
Route::match(['get', 'post'], '/city', [CityController::class, 'list'])->name('city');
|
Route::get('/city', [CityController::class, 'list'])->name('city');
|
||||||
Route::match(['get', 'post'], '/city/add', [CityController::class, 'add'])->name('city_add');
|
Route::get('/city/add', [CityController::class, 'add'])->name('city.add');
|
||||||
Route::match(['get', 'post'], '/city/edit/{id}', [CityController::class, 'edit'])->where(['id' => '[0-9]+'])->name('city_edit');
|
Route::post('/city/add', [CityController::class, 'store'])->name('city.store');
|
||||||
Route::match(['get', 'post'], '/city/info/{id}', [CityController::class, 'info'])->where(['id' => '[0-9]+'])->name('city_info');
|
Route::get('/city/edit/{id}', [CityController::class, 'edit'])
|
||||||
Route::match(['get', 'post'], '/city/delete', [CityController::class, 'delete'])->name('city_delete');
|
->whereNumber('id')
|
||||||
|
->name('city.edit');
|
||||||
|
Route::put('/city/edit/{id}', [CityController::class, 'update'])
|
||||||
|
->whereNumber('id')
|
||||||
|
->name('city.update');
|
||||||
|
Route::post('/city/delete', [CityController::class, 'delete'])->name('city.delete');
|
||||||
|
|
||||||
|
|
||||||
//2026.02.05 kin
|
//2026.02.05 kin
|
||||||
// 駐輪場マスタ
|
// 駐輪場マスタ
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user