This commit is contained in:
parent
26f1d82dae
commit
b0ed603472
@ -16,7 +16,6 @@ class StationController extends Controller
|
||||
$sort = $request->input('sort', 'station_id');
|
||||
$sort_type = $request->input('sort_type', 'asc');
|
||||
|
||||
// 許可されたソート項目のみ
|
||||
$allowedSorts = [
|
||||
'station_id',
|
||||
'park_id',
|
||||
@ -32,19 +31,23 @@ class StationController extends Controller
|
||||
$sort_type = 'asc';
|
||||
}
|
||||
|
||||
// 必要カラムのみ取得
|
||||
$stations = Station::select([
|
||||
'station_id',
|
||||
'station_neighbor_station',
|
||||
'station_name_ruby',
|
||||
'station_route_name',
|
||||
'park_id',
|
||||
'operator_id'
|
||||
])->orderBy($sort, $sort_type)->paginate(20);
|
||||
$list = Station::select([
|
||||
'station_id',
|
||||
'station_neighbor_station',
|
||||
'station_name_ruby',
|
||||
'station_route_name',
|
||||
'park_id',
|
||||
'operator_id',
|
||||
'station_latitude',
|
||||
'station_longitude',
|
||||
])
|
||||
->orderBy($sort, $sort_type)
|
||||
->paginate(20);
|
||||
|
||||
return view('admin.stations.list', compact('stations', 'sort', 'sort_type'));
|
||||
return view('admin.stations.list', compact('list', 'sort', 'sort_type'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新規登録
|
||||
*/
|
||||
|
||||
@ -11,140 +11,144 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@php
|
||||
// $isEdit = 1 or 0
|
||||
@endphp
|
||||
|
||||
<div class="card-body">
|
||||
<table class="table table-borderless">
|
||||
{{-- 近傍駅ID(自動採番) --}}
|
||||
<tr>
|
||||
<th>{{ __('近傍駅ID') }}</th>
|
||||
<td>
|
||||
{{-- バリデーションエラー表示 --}}
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul class="mb-0">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- 近傍駅ID(自動採番) -->
|
||||
<div class="col-3">
|
||||
<label>{{ __('近傍駅ID') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" name="station_id"
|
||||
class="form-control text-right bg-light"
|
||||
value="{{ old('station_id', $station->station_id ?? '') }}"
|
||||
maxlength="10" readonly>
|
||||
</td>
|
||||
</tr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 駐輪場ID --}}
|
||||
<tr>
|
||||
<th>{{ __('駐車場ID') }}</th>
|
||||
<td>
|
||||
<!-- 駐輪場ID -->
|
||||
<div class="col-3">
|
||||
<label>{{ __('駐車場ID') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" name="park_id"
|
||||
class="form-control text-right bg-light"
|
||||
value="{{ old('park_id', $station->park_id ?? '') }}"
|
||||
maxlength="10" readonly>
|
||||
</td>
|
||||
</tr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 近傍駅 --}}
|
||||
<tr>
|
||||
<th>{{ __('近傍駅') }} <span class="text-danger">※</span></th>
|
||||
<td>
|
||||
<!-- 近傍駅 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('近傍駅') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" name="station_neighbor_station"
|
||||
class="form-control text-left"
|
||||
class="form-control"
|
||||
value="{{ old('station_neighbor_station', $station->station_neighbor_station ?? '') }}"
|
||||
maxlength="10" required>
|
||||
@error('station_neighbor_station')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
maxlength="50" required>
|
||||
</div>
|
||||
@error('station_neighbor_station')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- 近傍駅ふりがな --}}
|
||||
<tr>
|
||||
<th>{{ __('近傍駅ふりがな') }} <span class="text-danger">※</span></th>
|
||||
<td>
|
||||
<!-- 近傍駅ふりがな -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('近傍駅ふりがな') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" name="station_name_ruby"
|
||||
class="form-control text-left"
|
||||
class="form-control"
|
||||
value="{{ old('station_name_ruby', $station->station_name_ruby ?? '') }}"
|
||||
maxlength="10" required>
|
||||
@error('station_name_ruby')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
maxlength="50" required>
|
||||
</div>
|
||||
@error('station_name_ruby')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- 路線名 --}}
|
||||
<tr>
|
||||
<th>{{ __('路線名') }} <span class="text-danger">※</span></th>
|
||||
<td>
|
||||
<!-- 路線名 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('路線名') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" name="station_route_name"
|
||||
class="form-control text-left"
|
||||
class="form-control"
|
||||
value="{{ old('station_route_name', $station->station_route_name ?? '') }}"
|
||||
maxlength="10" required>
|
||||
@error('station_route_name')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
maxlength="50" required>
|
||||
</div>
|
||||
@error('station_route_name')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- 緯度 --}}
|
||||
<tr>
|
||||
<th>{{ __('近傍駅座標(緯度)') }} <span class="text-danger">※</span></th>
|
||||
<td>
|
||||
<!-- 緯度 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('近傍駅座標(緯度)') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="number" name="latitude"
|
||||
class="form-control text-left"
|
||||
class="form-control"
|
||||
value="{{ old('latitude', $station->latitude ?? '') }}"
|
||||
step="any" maxlength="10" required>
|
||||
@error('latitude')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
step="any" maxlength="20" required>
|
||||
</div>
|
||||
@error('latitude')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- 経度 --}}
|
||||
<tr>
|
||||
<th>{{ __('近傍駅座標(経度)') }} <span class="text-danger">※</span></th>
|
||||
<td>
|
||||
<!-- 経度 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('近傍駅座標(経度)') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="number" name="longitude"
|
||||
class="form-control text-l"
|
||||
class="form-control"
|
||||
value="{{ old('longitude', $station->longitude ?? '') }}"
|
||||
step="any" maxlength="10" required>
|
||||
@error('longitude')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
step="any" maxlength="20" required>
|
||||
</div>
|
||||
@error('longitude')
|
||||
<div class="text-danger small">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- 登録・削除 ボタン --}}
|
||||
<div class="text-left mt-4">
|
||||
@if($isInfo)
|
||||
{{-- 詳細画面:編集に遷移 --}}
|
||||
</div>
|
||||
|
||||
<a href="{{ route('stations_edit', ['id' => $station->id]) }}" class="btn btn-lg btn-success">
|
||||
編集
|
||||
</a>
|
||||
@else
|
||||
{{-- 新規/編集 共通フォーム --}}
|
||||
<button type="submit" class="btn btn-lg btn-success">
|
||||
{{ $isEdit ? '更新' : '登録' }}
|
||||
</button>
|
||||
{{-- ▼ 下部ボタン --}}
|
||||
<div class="form-group col-12 d-flex gap-2 mt-4">
|
||||
{{-- 登録ボタン --}}
|
||||
<button type="submit" class="btn btn-lg btn-success mr-2">{{ __('登録') }}</button>
|
||||
|
||||
{{-- 編集時のみ削除可能 --}}
|
||||
@if($isEdit && isset($station->id))
|
||||
<form id="delete-form" method="POST"
|
||||
action="{{ route('stations_delete') }}"
|
||||
style="display:inline;">
|
||||
@csrf
|
||||
<input type="hidden" name="pk[]" value="{{ $station->id }}">
|
||||
<button type="submit" class="btn btn-lg btn-danger ml-2"
|
||||
onclick="return confirm('削除してよろしいですか?')">削除</button>
|
||||
</form>
|
||||
@endif
|
||||
{{-- 削除ボタン(編集画面のみ表示) --}}
|
||||
@if(!empty($station->station_id))
|
||||
</form>
|
||||
<form method="POST" action="{{ route('stations_delete') }}"
|
||||
onsubmit="return confirm('本当に削除しますか?')" class="d-inline-block">
|
||||
@csrf
|
||||
<input type="hidden" name="pk" value="{{ $station->station_id }}">
|
||||
<button type="submit" class="btn btn-lg btn-danger mr-2">{{ __('削除') }}</button>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
function confirmDelete() {
|
||||
if (confirm('削除してよろしいですか?')) {
|
||||
document.getElementById('delete-form').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
|
||||
@ -24,11 +24,7 @@
|
||||
<div class="card">
|
||||
<form method="POST" action="{{ route('stations_add') }}">
|
||||
@csrf
|
||||
@include('admin.stations._form', [
|
||||
'isEdit' => 0,
|
||||
'isInfo' => 0,
|
||||
'station' => $station ?? null
|
||||
])
|
||||
@include('admin.stations._form', ['isEdit' => false])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,11 +26,7 @@
|
||||
<div class="card">
|
||||
<form method="POST" action="{{ route('stations_edit', ['id' => $station->station_id]) }}">
|
||||
@csrf
|
||||
@include('admin.stations._form', [
|
||||
'isEdit' => 1,
|
||||
'isInfo' => 0,
|
||||
'station' => $station
|
||||
])
|
||||
@include('admin.stations._form', ['isEdit' => true])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
<!-- Main Content -->
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
|
||||
{{-- 並び替え用 hidden --}}
|
||||
<form action="{{ route('stations') }}" method="POST" id="list-form">
|
||||
@csrf
|
||||
@ -30,15 +31,27 @@
|
||||
<input type="hidden" name="sort_type" value="{{ $sort_type ?? '' }}">
|
||||
</form>
|
||||
|
||||
<div class="container-fluid mb20">
|
||||
{{-- ▼ ボタンエリア --}}
|
||||
<div class="col-lg-12 mb-3">
|
||||
<button type="button" class="btn btn-sm btn-default mr10" onclick="location.href='{{ route('stations_add') }}'">新規</button>
|
||||
<button type="button" class="btn btn-sm btn-default mr10" id="delete">削除</button>
|
||||
{{-- 削除 --}}
|
||||
<button type="submit" class="btn btn-sm btn-default mr10"
|
||||
form="form_delete" name="delete"
|
||||
onclick="return confirm('選択した項目を削除しますか?');">削除</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10" form="form_export">{{ __('CSV出力') }}</button>
|
||||
<div class="d-flex justify-content-end">
|
||||
{{ $stations->appends(['sort' => $sort ?? '', 'sort_type' => $sort_type ?? ''])->links('pagination') }}
|
||||
</div>
|
||||
|
||||
{{-- ▼ ページネーション --}}
|
||||
<div class="col-lg-12">
|
||||
<div class="d-flex justify-content-end mb-3">
|
||||
{{ $list->appends([
|
||||
'sort' => $sort ?? '',
|
||||
'sort_type' => $sort_type ?? ''
|
||||
])->links('pagination') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- ▼ テーブル --}}
|
||||
<div class="form col-lg-12">
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
@ -52,15 +65,7 @@
|
||||
{!! Session::get('error') !!}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- メッセージ表示 -->
|
||||
<div class="col-lg-12">
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success alert-dismissible">{{ session('success') }}</div>
|
||||
@elseif(session('error'))
|
||||
<div class="alert alert-danger alert-dismissible">{{ session('error') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ▼ ここから単一テーブル構成 ----------------------------------------- -->
|
||||
<div class="col-lg-12 mb20">
|
||||
@ -80,12 +85,13 @@
|
||||
<th class="sorting {{ ($sort=='station_neighbor_station') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="station_neighbor_station"><span>近傍駅</span></th>
|
||||
<th class="sorting {{ ($sort=='station_name_ruby') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="station_name_ruby"><span>近傍駅ふりがな</span></th>
|
||||
<th class="sorting {{ ($sort=='station_route_name') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="station_route_name"><span>路線名</span></th>
|
||||
<th><span>近傍駅座標(緯度)</span></th>
|
||||
<th><span>近傍駅座標(経度)</span></th>
|
||||
<th>{{ __('近傍駅座標(緯度)') }}</th>
|
||||
<th>{{ __('近傍駅座標(経度)') }}</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white">
|
||||
@foreach($stations as $station)
|
||||
@foreach($list as $station)
|
||||
<tr>
|
||||
{{-- ★ 同じセル内に チェック + 編集ボタン) --}}
|
||||
<td class="align-middle" style="background-color:#faebd7;">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user