From aa91bc6617bc516e5e221cf19bdba0b56f4f1d74 Mon Sep 17 00:00:00 2001 From: "kin.rinzen" Date: Tue, 28 Oct 2025 15:02:18 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A5=91=E7=B4=84=E8=A8=B1=E5=AE=B9=E5=B8=82?= =?UTF-8?q?=E5=8C=BA=E3=81=AE=E3=83=AA=E3=82=B9=E3=83=88=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/ContractAllowableCityController.php | 1 - app/Models/ContractAllowableCity.php | 18 +++++++++++++----- .../contract_allowable_cities/list.blade.php | 6 ++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Admin/ContractAllowableCityController.php b/app/Http/Controllers/Admin/ContractAllowableCityController.php index f203947..8770449 100644 --- a/app/Http/Controllers/Admin/ContractAllowableCityController.php +++ b/app/Http/Controllers/Admin/ContractAllowableCityController.php @@ -48,7 +48,6 @@ class ContractAllowableCityController extends Controller $query->where('park_id', $request->park_id); } - // 推荐:直接批量删除 $count = $query->delete(); return redirect()->route('contract_allowable_cities')->with('success', '解除しました'); } diff --git a/app/Models/ContractAllowableCity.php b/app/Models/ContractAllowableCity.php index 03ef707..5b20f58 100644 --- a/app/Models/ContractAllowableCity.php +++ b/app/Models/ContractAllowableCity.php @@ -28,20 +28,27 @@ class ContractAllowableCity extends Model */ public static function search($inputs) { - $list = self::query(); + $list = self::query() + ->leftJoin('park', 'contract_allowable_city.park_id', '=', 'park.park_id') + ->leftJoin('city', 'contract_allowable_city.city_id', '=', 'city.city_id') + ->select( + 'contract_allowable_city.*', + 'park.park_name', + 'city.city_name' + ); if ($inputs['isMethodPost'] ?? false) { if (!empty($inputs['contract_allowable_city_id'])) { - $list->where('contract_allowable_city_id', $inputs['contract_allowable_city_id']); + $list->where('contract_allowable_city.contract_allowable_city_id', $inputs['contract_allowable_city_id']); } if (!empty($inputs['city_id'])) { - $list->where('city_id', $inputs['city_id']); + $list->where('contract_allowable_city.city_id', $inputs['city_id']); } if (!empty($inputs['contract_allowable_city_name'])) { - $list->where('contract_allowable_city_name', 'like', '%' . $inputs['contract_allowable_city_name'] . '%'); + $list->where('contract_allowable_city.contract_allowable_city_name', 'like', '%' . $inputs['contract_allowable_city_name'] . '%'); } if (!empty($inputs['park_id'])) { - $list->where('park_id', $inputs['park_id']); + $list->where('contract_allowable_city.park_id', $inputs['park_id']); } } @@ -57,6 +64,7 @@ class ContractAllowableCity extends Model } } + /** * 主キーで取得 */ diff --git a/resources/views/admin/contract_allowable_cities/list.blade.php b/resources/views/admin/contract_allowable_cities/list.blade.php index 7f44bbe..09461f3 100644 --- a/resources/views/admin/contract_allowable_cities/list.blade.php +++ b/resources/views/admin/contract_allowable_cities/list.blade.php @@ -130,9 +130,11 @@ {{ $item->contract_allowable_city_id }} - {{ $item->city_id }} + {{ $item->city_name }} {{ $item->contract_allowable_city_name }} - {{ $item->park_id }} + {{ $item->park_name }} + + {{ $item->same_district_flag == 0 ? '隣接市' : 'その他' }} @endforeach