This commit is contained in:
parent
d1277a2b4a
commit
e3201a680e
@ -24,7 +24,7 @@ class PplaceController extends Controller
|
||||
$inputs['list'] = Pplace::search($inputs);
|
||||
|
||||
if ($inputs['list']->total() > 0 && $inputs['page'] > $inputs['list']->lastPage()) {
|
||||
return redirect()->route('pplace');
|
||||
return redirect()->route('pplaces');
|
||||
}
|
||||
|
||||
return view('admin.Pplace.list', $inputs);
|
||||
@ -53,7 +53,7 @@ class PplaceController extends Controller
|
||||
$pplace->fill($inputs);
|
||||
$pplace->save();
|
||||
});
|
||||
return redirect()->route('pplace')->with('success', '登録成功');
|
||||
return redirect()->route('pplaces')->with('success', '登録しました。');
|
||||
} else {
|
||||
$inputs['errorMsg'] = $this->__buildErrorMessasges($validator);
|
||||
}
|
||||
@ -88,7 +88,7 @@ class PplaceController extends Controller
|
||||
$record->fill($inputs);
|
||||
$record->save();
|
||||
});
|
||||
return redirect()->route('pplace')->with('success', '更新成功');
|
||||
return redirect()->route('pplaces')->with('success', '更新成功');
|
||||
} else {
|
||||
$data['errorMsg'] = $this->__buildErrorMessasges($validator);
|
||||
}
|
||||
@ -104,13 +104,22 @@ class PplaceController extends Controller
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$pk = $request->get('pk');
|
||||
if ($pk && Pplace::destroy($pk)) {
|
||||
return redirect()->route('pplace')->with('success', '削除成功');
|
||||
$arr_pk = $request->get('pk');
|
||||
|
||||
if ($arr_pk) {
|
||||
$ids = is_array($arr_pk) ? $arr_pk : [$arr_pk];
|
||||
|
||||
if (Pplace::deleteByPk($ids)) {
|
||||
return redirect()->route('pplaces')->with('success', __("削除成功しました。"));
|
||||
} else {
|
||||
return redirect()->route('pplaces')->with('error', __('削除に失敗しました。'));
|
||||
}
|
||||
}
|
||||
return redirect()->route('pplace')->with('error', '削除失敗');
|
||||
|
||||
return redirect()->route('pplaces')->with('error', __('削除するデータを選択してください。'));
|
||||
}
|
||||
|
||||
|
||||
public function export()
|
||||
{
|
||||
$headers = [
|
||||
@ -142,7 +151,7 @@ class PplaceController extends Controller
|
||||
{
|
||||
$file = $request->file('file');
|
||||
if (!$file) {
|
||||
return redirect()->route('pplace')->with('error', 'CSVファイルを選択してください');
|
||||
return redirect()->route('pplaces')->with('error', 'CSVファイルを選択してください');
|
||||
}
|
||||
|
||||
$data = \App\Utils::csvToArray($file);
|
||||
@ -161,10 +170,10 @@ class PplaceController extends Controller
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
return redirect()->route('pplace')->with('success', 'インポート成功');
|
||||
return redirect()->route('pplaces')->with('success', 'インポート成功');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return redirect()->route('pplace')->with('error', "行 {$record} : " . $e->getMessage());
|
||||
return redirect()->route('pplaces')->with('error', "行 {$record} : " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,11 +65,15 @@ class Pplace extends Model
|
||||
/**
|
||||
* 主キー配列で一括削除
|
||||
*/
|
||||
public static function deleteByPk($arr)
|
||||
public static function deleteByPk($ids)
|
||||
{
|
||||
return self::whereIn('pplace_id', $arr)->delete();
|
||||
if (!is_array($ids)) {
|
||||
$ids = [$ids];
|
||||
}
|
||||
return self::whereIn('pplace_id', $ids)->delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 選択リスト取得用(フォーム等)
|
||||
*/
|
||||
|
||||
@ -17,19 +17,9 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card-header">
|
||||
@if($isInfo)
|
||||
<a href="{{ route('pplace_add') }}" class="btn btn-lg btn-success">{{ __('登録') }}</a>
|
||||
<a href="{{ route('pplace_edit', ['id' => $pplace_id]) }}" class="btn btn-lg btn-danger">{{ __('編集') }}</a>
|
||||
@else
|
||||
<button type="submit" class="btn btn-lg btn-danger register">{{ __('保存') }}</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
{{-- 駐輪車室ID --}}
|
||||
@if($isInfo || $isEdit)
|
||||
<div class="form-group col-3">
|
||||
<label>{{ __('駐輪車室ID') }}</label>
|
||||
</div>
|
||||
@ -39,16 +29,15 @@
|
||||
name="pplace_id" class="form-control form-control-lg" readonly />
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- 番号 --}}
|
||||
<div class="form-group col-3">
|
||||
<label @if(!$isInfo) class="required" @endif>{{ __('駐輪車室番号') }}</label>
|
||||
<label class="required">{{ __('駐輪車室番号') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" value="{{ $pplace_number ?? '' }}" placeholder="{{ __('駐輪車室番号') }}"
|
||||
name="pplace_number" class="form-control form-control-lg" @if($isInfo) readonly @endif />
|
||||
name="pplace_number" class="form-control form-control-lg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -59,28 +48,37 @@
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text" value="{{ $pplace_remarks ?? '' }}" placeholder="{{ __('備考') }}"
|
||||
name="pplace_remarks" class="form-control form-control-lg" @if($isInfo) readonly @endif />
|
||||
name="pplace_remarks" class="form-control form-control-lg" @if(!empty($isEdit))@endif />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- オペレーター --}}
|
||||
<!-- {{-- オペレーター --}}
|
||||
<div class="form-group col-3">
|
||||
<label>{{ __('更新オペレータID') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<select name="operator_id" class="form-control form-control-lg" @if($isInfo) disabled @endif>
|
||||
<select name="operator_id" class="form-control form-control-lg" @if(!empty($isEdit)) disabled @endif>
|
||||
<option value="">{{ __('選択してください') }}</option>
|
||||
@foreach($operators ?? [] as $id => $name)
|
||||
<option value="{{ $id }}" @if(($operator_id ?? '') == $id) selected @endif>{{ $name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
@if($isInfo)
|
||||
<a href="{{ route('pplace_add') }}" class="btn btn-lg btn-success">{{ __('登録') }}</a>
|
||||
<a href="{{ route('pplace_edit', ['id' => $pplace_id]) }}" class="btn btn-lg btn-danger">{{ __('編集') }}</a>
|
||||
@else
|
||||
<button type="submit" class="btn btn-lg btn-danger register">{{ __('保存') }}</button>
|
||||
<!-- <div class="text-center"> -->
|
||||
{{-- 登録ボタン --}}
|
||||
<button type="submit" class="btn btn-lg btn-success mr-2">{{ __('登録') }}</button>
|
||||
|
||||
{{-- 削除ボタン(編集画面のみ表示) --}}
|
||||
@if(!empty($pplace_id))
|
||||
</form>
|
||||
<form method="POST" action="{{ route('pplace_delete') }}"
|
||||
onsubmit="return confirm('本当に削除しますか?')" class="d-inline-block mr-2">
|
||||
@csrf
|
||||
<input type="hidden" name="pk" value="{{ $pplace_id }}">
|
||||
<button type="submit" class="btn btn-lg btn-danger mr-2">{{ __('削除') }}</button>
|
||||
</form>
|
||||
@endif
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
@ -7,13 +7,12 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-6">
|
||||
<h1 class="m-0 text-dark">[東京都|〇〇駐輪場] 駐輪車室マスタ</h1>
|
||||
<h1 class="m-0 text-dark">新規登録</h1>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<ol class="breadcrumb float-sm-right text-sm">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">XX様info(ホーム)</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">[東京都|〇〇駐輪場]</a></li>
|
||||
<li class="breadcrumb-item">駐輪車室マスタ</li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('pplaces') }}">駐輪車室マスタ</a></li>
|
||||
<li class="breadcrumb-item active">新規登録</li>
|
||||
</ol>
|
||||
</div>
|
||||
@ -36,11 +35,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid mb20">
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('削除') }}</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('インポート') }}</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('CSV出力') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
|
||||
@ -7,13 +7,12 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-6">
|
||||
<h1 class="m-0 text-dark">[東京都|〇〇駐輪場] 駐輪車室マスタ</h1>
|
||||
<h1 class="m-0 text-dark">編集</h1>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<ol class="breadcrumb float-sm-right text-sm">
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">XX様info(ホーム)</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">[東京都|〇〇駐輪場]</a></li>
|
||||
<li class="breadcrumb-item">駐輪車室マスタ</li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('pplaces') }}">駐輪車室マスタ</a></li>
|
||||
<li class="breadcrumb-item active">編集</li>
|
||||
</ol>
|
||||
</div>
|
||||
@ -30,17 +29,11 @@
|
||||
<div class="card">
|
||||
<form method="post" action="{{ route('pplace_edit', ['id' => $pplace_id]) }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('admin.pplace._form', ['isEdit' => 1, 'isInfo' => 0])
|
||||
@include('admin.pplace._form', ['isEdit' => true])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid mb20">
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('削除') }}</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('インポート') }}</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">{{ __('CSV出力') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
|
||||
@ -9,8 +9,7 @@
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<ol class="breadcrumb float-sm-right text-sm">
|
||||
<li class="breadcrumb-item"><a href="{{route('home')}}">XX様info(ホーム)</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">[東京都|〇〇駐輪場]</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{route('home')}}">ホーム</a></li>
|
||||
<li class="breadcrumb-item active">{{__('駐輪車室マスタ')}}</li>
|
||||
</ol>
|
||||
</div>
|
||||
@ -20,18 +19,31 @@
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<form action="{{route('pplace')}}" method='post' id='list-form'>
|
||||
|
||||
<form action="{{route('pplaces')}}" method='post' id='list-form'>
|
||||
@csrf
|
||||
<input type="hidden" value="{{$sort}}" name="sort" id="sort">
|
||||
<input type="hidden" value="{{$sort_type}}" name="sort_type" id="sort_type">
|
||||
</form>
|
||||
|
||||
<div class="container-fluid mb20">
|
||||
<button type="submit" class="btn btn-sm btn-default mr10" name="delete" id="delete">{{__('削除')}}</button>
|
||||
<button type="submit" class="btn btn-sm btn-default mr10" name="import_csv" id="import_csv" action="{{route('pplace_import')}}">{{__('インポート')}}</button>
|
||||
<button type="button" class="btn btn-sm btn-default mr10" onclick="location.href='{{ route('pplace_add') }}'">新規</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" name="import_csv" id="import_csv" action="{{route('pplace_import')}}">{{__('インポート')}}</button> -->
|
||||
<button type="submit" class="btn btn-sm btn-default mr10" name="export_csv" id="export_csv" action="{{route('pplace_export')}}">{{__('CSV出力')}}</button>
|
||||
{{ $list->appends(['sort' => $sort,'sort_type'=>$sort_type])->links('pagination') }}
|
||||
</div>
|
||||
|
||||
{{-- ▼ ページネーション --}}
|
||||
<div class="container-fluid">
|
||||
<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">
|
||||
@ -55,51 +67,39 @@
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 row sample03-wrapper no_padding_right mb20">
|
||||
<div class="col-xl-2 col-lg-2 col-md-2 col-sm-3 col-xs-3 table_left">
|
||||
<form action="{{route('pplace_delete')}}" method="post" id="form_delete">
|
||||
@csrf
|
||||
<table class="table dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" class="minimal m-0" id="checkbox_all"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($list as $item)
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" class="minimal m-0 checkbox" value="{{$item->pplace_id}}" name="pk[]">
|
||||
<div class="btn_action">
|
||||
<a href="{{route('pplace_info', ['id' => $item->pplace_id])}}" class="btn btn-sm btn-default ml10">{{__('編集')}}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-10 col-xl-10 col-md-10 col-sm-9 col-xs-9 table_right no_padding_right">
|
||||
<div class="scroll">
|
||||
<table class="table dataTable">
|
||||
<thead>
|
||||
<form action="{{route('pplace_delete')}}" method="post" id="form_delete">
|
||||
@csrf
|
||||
<!-- ▼ ここから単一テーブル構成 ----------------------------------------- -->
|
||||
<div class="col-lg-12 mb20">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered dataTable text-nowrap">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th style="width:140px; border-left:1px solid #dcdcdc;" class="text-left">
|
||||
<input type="checkbox" onclick="$('input[name*=\'pk\']').prop('checked', this.checked);">
|
||||
</th>
|
||||
<th class="sorting @if($sort=='pplace_id'){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif" sort="pplace_id">
|
||||
<span>{{__('ID')}}</span>
|
||||
<span>{{__('駐輪車室ID')}}</span>
|
||||
</th>
|
||||
<th class="sorting @if($sort=='pplace_number'){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif" sort="pplace_number">
|
||||
<span>{{__('番号')}}</span>
|
||||
<th>
|
||||
<span>{{__('駐輪車室番号')}}</span>
|
||||
</th>
|
||||
<th class="sorting @if($sort=='pplace_remarks'){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif" sort="pplace_remarks">
|
||||
<th>
|
||||
<span>{{__('備考')}}</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tbody class="bg-white">
|
||||
@foreach($list as $item)
|
||||
<tr>
|
||||
<td class="align-middle" style="background-color:#faebd7; border-left:1px solid #dcdcdc;">
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="checkbox" class="m-0 checkbox" name="pk[]" value="{{ $item->pplace_id }}">
|
||||
<a href="{{ route('pplace_edit', ['id' => $item->pplace_id]) }}"
|
||||
class="btn btn-sm btn-default ml10">編集</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class='sm-item text-left'><span>{{mb_substr($item->pplace_id, 0, 10)}}</span></td>
|
||||
<td class='sm-item text-left'><span>{{mb_substr($item->pplace_number, 0, 20)}}</span></td>
|
||||
<td class='sm-item text-left'><span>{{mb_substr($item->pplace_remarks, 0, 20)}}</span></td>
|
||||
@ -109,9 +109,8 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- ▲ ここまで単一テーブル構成 ----------------------------------------- -->
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@ -450,6 +450,7 @@
|
||||
'stations',
|
||||
'terms',
|
||||
'contract_allowable_cities',
|
||||
'pplace',
|
||||
];
|
||||
$current = app('router')->currentRouteName();
|
||||
@endphp
|
||||
@ -492,6 +493,10 @@
|
||||
<i class="fa fa-circle-o nav-icon"></i>
|
||||
<p>{{ __("ゾーンマスタ") }}</p></a>
|
||||
</li>
|
||||
<li class="nav-item"><a href="{{ route('pplaces') }}" class="nav-link @if($current === 'pplaces') active @endif">
|
||||
<i class="fa fa-circle-o nav-icon"></i>
|
||||
<p>{{ __("駐輪場室マスタ") }}</p></a>
|
||||
</li>
|
||||
<li class="nav-item"><a href="{{ route('regular_types') }}" class="nav-link @if($current === 'regular_types') active @endif">
|
||||
<i class="fa fa-circle-o nav-icon"></i>
|
||||
<p>{{ __("定期種別マスタ") }}</p></a>
|
||||
|
||||
@ -41,6 +41,7 @@ use App\Http\Controllers\Admin\SettingController;
|
||||
use App\Http\Controllers\Admin\MailTemplateController;
|
||||
use App\Http\Controllers\Admin\InvSettingController;
|
||||
use App\Http\Controllers\Admin\ZoneController;
|
||||
use App\Http\Controllers\Admin\PplaceController;
|
||||
|
||||
|
||||
/**
|
||||
@ -144,7 +145,7 @@ Route::middleware('auth')->group(function () {
|
||||
Route::get('/regular_contracts/export', [App\Http\Controllers\Admin\RegularContractController::class, 'export'])->name('regular_contracts_export');
|
||||
|
||||
// [東京都|〇〇駐輪場] 駐輪車室マスタ
|
||||
Route::match(['get', 'post'], '/pplace', [PplaceController::class, 'list'])->name('pplace');
|
||||
Route::match(['get', 'post'], '/pplace', [PplaceController::class, 'list'])->name('pplaces');
|
||||
Route::match(['get', 'post'], '/pplace/add', [PplaceController::class, 'add'])->name('pplace_add');
|
||||
Route::match(['get', 'post'], '/pplace/edit/{id}', [PplaceController::class, 'edit'])->name('pplace_edit')->where(['id' => '[0-9]+']);
|
||||
Route::match(['get', 'post'], '/pplace/info/{id}', [PplaceController::class, 'info'])->name('pplace_info')->where(['id' => '[0-9]+']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user