This commit is contained in:
parent
ed7d4482b8
commit
00a15f6a35
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Requests\PriceRequest;
|
||||
use App\Models\Park;
|
||||
use App\Models\Price;
|
||||
use App\Models\Pplace;
|
||||
use App\Models\Psection;
|
||||
use App\Models\Ptype;
|
||||
use App\Models\Usertype;
|
||||
@ -41,117 +42,92 @@ class PriceController extends Controller
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
// POST の場合のみバリデーション + 保存
|
||||
if ($request->isMethod('POST')) {
|
||||
|
||||
// ★ 1. 全角数字を半角に変換(例:123 → 123)
|
||||
$request->merge([
|
||||
'pplace_id' => mb_convert_kana($request->input('pplace_id'), 'n'),
|
||||
]);
|
||||
|
||||
// バリデーション
|
||||
$validated = $request->validate([
|
||||
'price_parkplaceid' => 'required|integer', // 駐車場所ID
|
||||
'park_id' => 'required|integer', // 駐輪場ID
|
||||
'prine_name' => 'required|string|max:255', // 商品名
|
||||
'price_month' => 'nullable|integer', // 期間(月)
|
||||
'user_categoryid' => 'required|integer', // 利用者分類ID
|
||||
'price' => 'required|numeric|min:0', // 駐輪料金(税込)
|
||||
'psection_id' => 'required|integer', // 車種区分ID
|
||||
'price_ptypeid' => 'required|integer', // 駐輪分類ID
|
||||
'pplace_id' => 'required|integer', // 駐車車室ID
|
||||
], [
|
||||
'pplace_id.integer' => '駐車車室ID は整数で入力してください。',
|
||||
]);
|
||||
|
||||
// DB 登録
|
||||
$type = false;
|
||||
\DB::transaction(function () use ($validated, &$type) {
|
||||
$new = new Price();
|
||||
$new->fill($validated);
|
||||
if ($new->save()) {
|
||||
$type = true;
|
||||
}
|
||||
});
|
||||
|
||||
// 結果
|
||||
if ($type) {
|
||||
return redirect()->route('prices')
|
||||
->with('success', __('新しい成功を創造する。'));
|
||||
} else {
|
||||
return redirect()->route('prices')
|
||||
->with('error', __('新しい作成に失敗しました。'));
|
||||
}
|
||||
if ($request->isMethod('get')) {
|
||||
return view('admin.prices.add', array_merge(
|
||||
$this->getDataDropList(),
|
||||
[
|
||||
'record' => new Price(),
|
||||
'isEdit' => false,
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
// GET の場合 → 画面表示
|
||||
$dataList = $this->getDataDropList();
|
||||
return view('admin.prices.add', $dataList);
|
||||
$request->merge([
|
||||
'pplace_id' => mb_convert_kana($request->input('pplace_id'), 'n'),
|
||||
]);
|
||||
|
||||
$validated = $this->validateRequest($request);
|
||||
|
||||
$created = false;
|
||||
\DB::transaction(function () use ($validated, &$created) {
|
||||
$price = new Price();
|
||||
$price->fill($validated);
|
||||
$created = $price->save();
|
||||
});
|
||||
|
||||
return redirect()->route('prices')
|
||||
->with($created ? 'success' : 'error', $created ? '登録しました。' : '登録に失敗しました。');
|
||||
}
|
||||
|
||||
|
||||
public function edit(Request $request, $pk ,$view='')
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$price = Price::getByPk($pk);
|
||||
if (empty($pk) || empty($price)) {
|
||||
$price = Price::getByPk($id);
|
||||
if (!$price) {
|
||||
abort(404);
|
||||
}
|
||||
$data = $price->getAttributes();
|
||||
$dataList = $this->getDataDropList();
|
||||
$data = array_merge($data, $dataList);
|
||||
|
||||
if ($request->isMethod('POST')) {
|
||||
$type = false;
|
||||
$requestAll = [
|
||||
'price_parkplaceid' => $request->input('price_parkplaceid'),
|
||||
'park_id' => $request->input('park_id'),
|
||||
'prine_name' => $request->input('prine_name'),
|
||||
'price_month' => $request->input('price_month',''),
|
||||
'user_categoryid' => $request->input('user_categoryid'),
|
||||
'price' => $request->input('price'),
|
||||
'psection_id' => $request->input('psection_id'),
|
||||
'price_ptypeid' => $request->input('price_ptypeid'),
|
||||
'pplace_id' => $request->input('pplace_id'),
|
||||
];
|
||||
$data = array_merge($data, $requestAll);
|
||||
|
||||
\DB::transaction(function () use ($data, &$type, $price) {
|
||||
$price->fill($data);
|
||||
$price->save();
|
||||
$type = true;
|
||||
});
|
||||
|
||||
if ($type) {
|
||||
return redirect()->route('prices')->with('success', __('更新に成功しました。'));
|
||||
} else {
|
||||
return redirect()->route('prices')->with('error', __('更新に失敗しました。'));
|
||||
}
|
||||
if ($request->isMethod('get')) {
|
||||
return view('admin.prices.edit', array_merge(
|
||||
$this->getDataDropList(),
|
||||
[
|
||||
'record' => $price,
|
||||
'isEdit' => true,
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
if ($view != '') {
|
||||
return view($view, $data);
|
||||
}
|
||||
$request->merge([
|
||||
'pplace_id' => mb_convert_kana($request->input('pplace_id'), 'n'),
|
||||
]);
|
||||
|
||||
return view('admin.prices.edit', $data);
|
||||
$validated = $this->validateRequest($request, $id);
|
||||
|
||||
$updated = false;
|
||||
\DB::transaction(function () use ($validated, &$updated, $price) {
|
||||
$price->fill($validated);
|
||||
$updated = $price->save();
|
||||
});
|
||||
|
||||
return redirect()->route('prices')
|
||||
->with($updated ? 'success' : 'error', $updated ? '更新しました。' : '更新に失敗しました。');
|
||||
}
|
||||
|
||||
|
||||
public function delete(Request $request)
|
||||
|
||||
public function delete(Request $request, $id = null)
|
||||
{
|
||||
$arr_pk = $request->get('pk');
|
||||
// 一覧画面(checkbox で複数削除)
|
||||
$ids = $request->input('pk');
|
||||
|
||||
if ($arr_pk) {
|
||||
$ids = is_array($arr_pk) ? $arr_pk : [$arr_pk];
|
||||
|
||||
if (Price::deleteByPk($ids)) {
|
||||
return redirect()->route('prices')->with('success', __("削除成功しました。"));
|
||||
} else {
|
||||
return redirect()->route('prices')->with('error', __('削除に失敗しました。'));
|
||||
}
|
||||
// 編集画面(単体削除)
|
||||
if ($id) {
|
||||
$ids = [$id];
|
||||
}
|
||||
|
||||
return redirect()->route('prices')->with('error', __('削除するユーザーを選択してください。'));
|
||||
// 削除対象が空
|
||||
if (empty($ids)) {
|
||||
return redirect()->route('prices')->with('error', '削除対象が選択されていません。');
|
||||
}
|
||||
|
||||
// 削除処理
|
||||
Price::destroy($ids);
|
||||
|
||||
return redirect()->route('prices')->with('success', '削除しました。');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function deleteByPk($ids)
|
||||
{
|
||||
if (!is_array($ids)) {
|
||||
@ -324,8 +300,33 @@ class PriceController extends Controller
|
||||
$data['psections'] = Psection::getList() ;
|
||||
$data['ptypes'] = Ptype::getList() ;
|
||||
$data['userTypes'] = Usertype::getList() ;
|
||||
$data['pplaces'] = Pplace::getList() ;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price バリデーション共通
|
||||
*/
|
||||
private function validateRequest(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'prine_name' => 'required|string|max:255',
|
||||
'price_month' => 'required|int',
|
||||
'park_id' => 'required|int',
|
||||
'psection_id' => 'required|int',
|
||||
'price_ptypeid' => 'required|int',
|
||||
'user_categoryid' => 'required|int',
|
||||
'pplace_id' => 'nullable|int',
|
||||
'park_number' => 'nullable|int',
|
||||
'park_standard' => 'nullable|int',
|
||||
'park_limit' => 'nullable|int',
|
||||
'price' => 'required|numeric',
|
||||
'operator_id' => 'nullable|int',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -45,9 +45,13 @@ class Price extends Model
|
||||
$query = self::query()
|
||||
->select(
|
||||
'price_a.*',
|
||||
\DB::raw("CONCAT_WS('/', usertype.usertype_subject1, usertype.usertype_subject2, usertype.usertype_subject3) as user_category_name")
|
||||
\DB::raw("CONCAT_WS('/', usertype.usertype_subject1, usertype.usertype_subject2, usertype.usertype_subject3) as user_category_name"),
|
||||
'psection.psection_subject',
|
||||
'ptype.ptype_subject'
|
||||
)
|
||||
->leftJoin('usertype', 'price_a.user_categoryid', '=', 'usertype.user_categoryid');
|
||||
->leftJoin('usertype', 'price_a.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->leftJoin('psection', 'price_a.psection_id', '=', 'psection.psection_id')
|
||||
->leftJoin('ptype', 'price_a.price_ptypeid', '=', 'ptype.ptype_id');
|
||||
|
||||
// ソート対象カラム
|
||||
$allowedSortColumns = [
|
||||
@ -111,4 +115,17 @@ class Price extends Model
|
||||
return $this->belongsTo(Usertype::class, 'user_categoryid', 'user_categoryid')->first();
|
||||
}
|
||||
|
||||
public function psection()
|
||||
{
|
||||
return $this->belongsTo(Psection::class, 'psection_id'); // 外部キーが psection_id
|
||||
|
||||
}
|
||||
public function ptype()
|
||||
{
|
||||
return $this->belongsTo(Ptype::class, 'price_ptypeid'); // 外部キーが price_ptypeid
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -419,6 +419,11 @@ return [
|
||||
'memo' => '備考',
|
||||
'subject' => '件名',
|
||||
'text' => '本文',
|
||||
//SWA-92
|
||||
'edit_master' => 'マスタ編集',
|
||||
'web_master' => 'ウェブ参照マスタ',
|
||||
'auto_change_date' => 'ウェブ参照マスタ自動切り替え日時',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,24 +1,4 @@
|
||||
<!-- {{-- アラート --}}
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@elseif(Session::has('error'))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('エラー') }}:</h4>
|
||||
{!! Session::get('error') !!}
|
||||
</div>
|
||||
@elseif(isset($errorMsg))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __(' 入力内容に不備があります。') }}:</h4>
|
||||
{!! $errorMsg !!}
|
||||
</div>
|
||||
@endif -->
|
||||
|
||||
{{-- アラート --}}
|
||||
{{-- ===== エラーメッセージ ===== --}}
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
@ -29,7 +9,7 @@
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<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>
|
||||
@foreach($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
|
||||
@ -12,16 +12,23 @@
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success">{{ session('success') }}</div>
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります') }}:</h4>
|
||||
<ul>
|
||||
@foreach($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="post" action="{{ route('inv_settings_save') }}" enctype="multipart/form-data">
|
||||
|
||||
@ -1,34 +1,27 @@
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@elseif(Session::has('error'))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}:</h4>
|
||||
{!! Session::get('error') !!}
|
||||
</div>
|
||||
@elseif(isset($errorMsg))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}:</h4>
|
||||
{!! $errorMsg !!}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<h4>入力内容に不備があります:</h4>
|
||||
<ol>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</div>
|
||||
{{-- ===== エラーメッセージ ===== --}}
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります') }}:</h4>
|
||||
<ul>
|
||||
@foreach($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="row">
|
||||
{{-- キューID(編集時のみ表示) --}}
|
||||
@if($isEdit)
|
||||
|
||||
@ -1,203 +1,213 @@
|
||||
{{-- アラート --}}
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ Session::get('success') }}
|
||||
</div>
|
||||
@elseif(Session::has('error'))
|
||||
@endif
|
||||
|
||||
@if($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('誤差') }}:</h4>
|
||||
{!! Session::get('error') !!}
|
||||
</div>
|
||||
@elseif(isset($errorMsg))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('誤差') }}:</h4>
|
||||
{!! $errorMsg !!}
|
||||
<h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります:') }}</h4>
|
||||
<ul>
|
||||
@foreach($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="card-body">
|
||||
{{-- バリデーションエラー表示 --}}
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul class="mb-0">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<!-- {{-- バリデーションエラー表示 --}}
|
||||
@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(※ 編集時のみ表示) --}}
|
||||
@if($isEdit)
|
||||
<div class="col-3 form-group">
|
||||
<label>{{ __('駐車場所ID') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<input type="text"
|
||||
name="price_parkplaceid"
|
||||
value="{{ old('price_parkplaceid', $record->price_parkplaceid ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
readonly
|
||||
placeholder="{{ __('validation.attributes.price_parkplaceid') }}">
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- 駐車場所ID -->
|
||||
<div class="col-3">
|
||||
<label class="required">{{ __('駐車場所ID') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<input type="text"
|
||||
name="price_parkplaceid"
|
||||
value="{{ old('price_parkplaceid', $price_parkplaceid ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
@if($isEdit) readonly @endif
|
||||
placeholder="駐車場所ID" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品名 -->
|
||||
<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="prine_name"
|
||||
value="{{ old('prine_name', $prine_name ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
placeholder="商品名" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 期間 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('期間') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<select name="price_month" class="form-control form-control-lg">
|
||||
<option value="">{{ __('期間') }}</option>
|
||||
@foreach(\App\Models\Price::PRICE_MONTH as $key => $item)
|
||||
<option value="{{ $key }}"
|
||||
@if($key == old('price_month', $price_month ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 駐輪場ID -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('駐輪場名') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<select name="park_id" class="form-control form-control-lg">
|
||||
<option value="">{{ __('駐輪場名') }}</option>
|
||||
@foreach($parks as $key => $item)
|
||||
<option value="{{ $key }}"
|
||||
@if($key == old('park_id', $park_id ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 車種区分名 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('車種区分名') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<select name="psection_id" class="form-control form-control-lg">
|
||||
<option value="">{{ __('車種区分名') }}</option>
|
||||
@foreach($psections as $key => $item)
|
||||
<option value="{{ $key }}"
|
||||
@if($key == old('psection_id', $psection_id ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 駐輪分類名 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('駐輪分類名') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<select name="price_ptypeid" class="form-control form-control-lg">
|
||||
<option value="">{{ __('駐輪分類名') }}</option>
|
||||
@foreach($ptypes as $key => $item)
|
||||
<option value="{{ $key }}"
|
||||
@if($key == old('price_ptypeid', $price_ptypeid ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 利用者分類 -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('利用者分類') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="input-group">
|
||||
<select name="user_categoryid" class="form-control form-control-lg">
|
||||
<option value="">{{ __('利用者分類') }}</option>
|
||||
@foreach($userTypes as $key => $item)
|
||||
<option value="{{ $key }}"
|
||||
@if($key == old('user_categoryid', $user_categoryid ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 駐車車室ID -->
|
||||
<div class="form-group col-3">
|
||||
<label class="required">{{ __('駐車車室ID') }}</label>
|
||||
{{-- 商品名 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('商品名') }}</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<input type="text"
|
||||
name="pplace_id"
|
||||
value="{{ old('pplace_id', $pplace_id ?? '') }}"
|
||||
name="prine_name"
|
||||
value="{{ old('prine_name', $record->prine_name ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
placeholder="駐車車室ID">
|
||||
|
||||
@error('pplace_id')
|
||||
<div class="text-danger">{{ $message }}</div>
|
||||
@enderror
|
||||
placeholder="{{ __('validation.attributes.prine_name') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 期間 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('期間') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="price_month" class="form-control form-control-lg">
|
||||
<option value="">{{ __('期間') }}</option>
|
||||
@foreach(\App\Models\Price::PRICE_MONTH as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('price_month', $record->price_month ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 駐輪料金(税込) -->
|
||||
<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="price"
|
||||
value="{{ old('price', $price ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
placeholder="駐輪料金(税込)"
|
||||
step="1" min="0" required>
|
||||
</div>
|
||||
{{-- 駐輪場名 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('駐輪場名') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="park_id" class="form-control form-control-lg">
|
||||
<option value="">{{ __('駐輪場名') }}</option>
|
||||
@foreach($parks as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('park_id', $record->park_id ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 車種区分名 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('車種区分名') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="psection_id" class="form-control form-control-lg">
|
||||
<option value="">{{ __('車種区分名') }}</option>
|
||||
@foreach($psections as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('psection_id', $record->psection_id ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 駐輪分類名 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('駐輪分類名') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="price_ptypeid" class="form-control form-control-lg">
|
||||
<option value="">{{ __('駐輪分類名') }}</option>
|
||||
@foreach($ptypes as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('price_ptypeid', $record->price_ptypeid ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 利用者分類 --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('利用者分類') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="user_categoryid" class="form-control form-control-lg">
|
||||
<option value="">{{ __('validation.attributes.user_categoryid') }}</option>
|
||||
@foreach($userTypes as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('user_categoryid', $record->user_categoryid ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- ▼ 下部ボタン --}}
|
||||
<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(!empty($price_parkplaceid))
|
||||
</form>
|
||||
<form method="POST" action="{{ route('prices_delete') }}"
|
||||
onsubmit="return confirm('本当に削除しますか?')" class="d-inline-block mr-2">
|
||||
@csrf
|
||||
<input type="hidden" name="pk" value="{{ $price_parkplaceid }}">
|
||||
<button type="submit" class="btn btn-lg btn-danger mr-2">{{ __('削除') }}</button>
|
||||
</form>
|
||||
@endif
|
||||
{{-- 駐車車室ID --}}
|
||||
<div class="col-3 form-group">
|
||||
<label>{{ __('駐車車室ID') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<select name="pplace_id" class="form-control form-control-lg">
|
||||
<option value="">{{ __('validation.attributes.pplace_id') }}</option>
|
||||
@foreach($pplaces as $key => $item)
|
||||
<option value="{{ $key }}" @if($key == old('pplace_id', $record->pplace_id ?? '')) selected @endif>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
{{-- 駐輪料金(税込) --}}
|
||||
<div class="col-3 form-group">
|
||||
<label class="required">{{ __('駐輪料金(税込)') }}</label>
|
||||
</div>
|
||||
<div class="col-9 form-group">
|
||||
<div class="input-group">
|
||||
<input type="number"
|
||||
step="0.01"
|
||||
name="price"
|
||||
value="{{ old('price', $record->price ?? '') }}"
|
||||
class="form-control form-control-lg"
|
||||
placeholder="{{ __('validation.attributes.price') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div> {{-- /.row --}}
|
||||
|
||||
{{-- ▼ 下部ボタン --}}
|
||||
<div class="row mt-4">
|
||||
<div class="form-group col-md-10 d-flex align-items-center gap-2 justify-content-start">
|
||||
|
||||
{{-- 登録ボタン --}}
|
||||
@if ($isEdit ?? false)
|
||||
<button type="button" id="register_edit" class="btn btn-lg btn-success mr-2">
|
||||
{{ __('登録') }}
|
||||
</button>
|
||||
@else
|
||||
<button type="button" id="register" class="btn btn-lg btn-success mr-2 register">
|
||||
{{ __('登録') }}
|
||||
</button>
|
||||
@endif
|
||||
|
||||
{{-- 削除ボタン(編集時のみ表示) --}}
|
||||
@if ($isEdit ?? false)
|
||||
<button type="button" id="delete_edit" class="btn btn-lg btn-danger">
|
||||
{{ __('削除') }}
|
||||
</button>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> {{-- /.card-body --}}
|
||||
|
||||
@ -24,11 +24,25 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<form method="POST" action="{{ route('price_edit', ['id' => $price_parkplaceid]) }}" enctype="multipart/form-data">
|
||||
{{-- 編集フォーム --}}
|
||||
<form id="form_edit"
|
||||
action="{{ route('price_edit', ['id' => $record->price_parkplaceid]) }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
@include('admin.prices._form', ['isEdit' => true])
|
||||
@include('admin.prices._form', ['isEdit' => true, 'record' => $record])
|
||||
</form>
|
||||
|
||||
{{-- 削除フォーム --}}
|
||||
<form id="form_delete"
|
||||
action="{{ route('prices_delete') }}"
|
||||
method="POST"
|
||||
style="display:none;">
|
||||
@csrf
|
||||
<input type="hidden" name="pk[]" value="{{ $record->price_parkplaceid }}">
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
|
||||
@extends('layouts.app')
|
||||
@section('title', '駐輪場所、料金マスタ')
|
||||
|
||||
@section('content')
|
||||
<!-- Content Header (Page header) -->
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-6">
|
||||
<h1 class="m-0 text-dark">駐輪場所、料金マスタ</h1>
|
||||
</div><!-- /.col -->
|
||||
<div class="col-lg-6">
|
||||
<ol class="breadcrumb float-sm-right text-sm">
|
||||
<li class="breadcrumb-item"><a href="./index2.html">ホーム</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{ route('prices') }}">駐輪場所、料金マスタ</a></li>
|
||||
<li class="breadcrumb-item active">編集</li>
|
||||
</ol>
|
||||
</div><!-- /.col -->
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</div>
|
||||
<!-- /.content-header -->
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<!-- SELECT2 EXAMPLE -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<form method="post" action="{{ route('price_info',['id'=>$price_parkplaceid])}}" enctype="multipart/form-data">
|
||||
<!-- TOKEN FORM -->
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}" >
|
||||
<!-- / .TOKEN FORM -->
|
||||
@include('admin.prices._form',['isEdit'=>0,'isInfo'=>1])
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
|
||||
@endsection
|
||||
@ -1,5 +1,5 @@
|
||||
@extends('layouts.app')
|
||||
@section('title', '[東京都|〇〇駐輪場] 駐輪場所、料金マスタ')
|
||||
@section('title', '駐輪場所、料金マスタ')
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -39,18 +39,19 @@
|
||||
onclick="location.href='{{ route('price_add') }}'">新規</button>
|
||||
|
||||
{{-- 削除 --}}
|
||||
<button type="submit" class="btn btn-sm btn-default mr10"
|
||||
form="form_delete" name="delete"
|
||||
onclick="return confirm('選択した項目を削除しますか?');">削除</button>
|
||||
<button type="button" class="btn btn-sm btn-default mr10" id="delete">{{ __('削除') }}</button>
|
||||
|
||||
{{-- CSV出力(全件 or ソート条件付き)--}}
|
||||
{{-- CSV出力(全件 or ソート条件付き) --}}
|
||||
<form id="form_export" method="POST" action="{{ route('prices_export') }}" class="d-inline">
|
||||
@csrf
|
||||
<input type="hidden" name="sort" value="{{ $sort ?? '' }}">
|
||||
<input type="hidden" name="sort_type" value="{{ $sort_type ?? '' }}">
|
||||
<button type="submit" class="btn btn-sm btn-default mr10">CSV出力</button>
|
||||
<button type="button" class="btn btn-sm btn-default mr10" id="btn_export_csv">CSV出力</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
{{-- エクスポート(条件選択モーダル) --}}
|
||||
<button type="button" class="btn btn-sm btn-default mr10" data-toggle="modal" data-target="#exportModal">
|
||||
エクスポート
|
||||
@ -134,13 +135,13 @@
|
||||
@elseif(Session::has('error'))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<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>
|
||||
{!! Session::get('error') !!}
|
||||
</div>
|
||||
@elseif(isset($errorMsg))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<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>
|
||||
{!! $errorMsg !!}
|
||||
</div>
|
||||
@endif
|
||||
@ -182,7 +183,7 @@
|
||||
<th><span>利用者分類ID</span></th>
|
||||
<th><span>駐輪料金(税込)</span></th>
|
||||
<th class="sorting {{ ($sort=='psection_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="psection_id"><span>車種区分ID</span></th>
|
||||
<th class="sorting {{ ($sort=='price_ptypeid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="price_ptypeid"><span>駐輪分類</span></th>
|
||||
<th class="sorting {{ ($sort=='price_ptypeid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="price_ptypeid"><span>駐輪分類ID</span></th>
|
||||
<th class="sorting {{ ($sort=='pplace_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="pplace_id"><span>駐車車室ID</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -207,8 +208,9 @@
|
||||
<td class="sm-item text-left align-middle">{{ $item->price_month }}ヶ月</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->user_category_name }}</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->price }}</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->psection_id }}</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->price_ptypeid }}</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->psection_subject?? '' }}</td>
|
||||
|
||||
<td class="sm-item text-left align-middle">{{ $item->ptype_subject?? '' }}</td>
|
||||
<td class="sm-item text-left align-middle">{{ $item->pplace_id }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@ -221,34 +223,67 @@
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{-- ▼ 全選択/全解除(name="pk[]" を対象) --}}
|
||||
<script>
|
||||
document.getElementById('checkbox_all')?.addEventListener('change', function(e){
|
||||
document.querySelectorAll('input[name="pk[]"]').forEach(function(el){
|
||||
el.checked = e.target.checked;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(function(){
|
||||
$('.sorting').click(function(){
|
||||
let sort = $(this).attr('sort');
|
||||
let currentSort = $('input[name="sort"]').val();
|
||||
let currentType = $('input[name="sort_type"]').val();
|
||||
let newType = 'asc';
|
||||
<!-- 载入 jQuery 和 jquery-confirm 工具包(从 CDN) -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.js"></script>
|
||||
|
||||
if (sort === currentSort) {
|
||||
newType = (currentType === 'asc') ? 'desc' : 'asc';
|
||||
<!-- CSV 出力脚本 -->
|
||||
<script>
|
||||
$(function() {
|
||||
// ▼ CSV出力ボタン押下
|
||||
$('#btn_export_csv').on('click', function () {
|
||||
const _action = $(this).closest('form').attr('action') || '';
|
||||
|
||||
const park_id = $('#park_id').val() || '';
|
||||
const user_category_id = $('#user_category_id').val() || '';
|
||||
const price_parkplaceid = $('#price_parkplaceid').val() || '';
|
||||
const prine_name = $('#prine_name').val() || '';
|
||||
const ptype_id = $('#ptype_id').val() || '';
|
||||
const psection_id = $('#psection_id').val() || '';
|
||||
const pplace_id = $('#pplace_id').val() || '';
|
||||
const sort = $('input[name="sort"]').val() || '';
|
||||
const sort_type = $('input[name="sort_type"]').val() || '';
|
||||
|
||||
$.confirm({
|
||||
title: '確認ダイアログ',
|
||||
content: 'CSVファイルを出力します。よろしいですか?',
|
||||
buttons: {
|
||||
ok: {
|
||||
text: 'はい',
|
||||
btnClass: 'btn-primary',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
const url =
|
||||
`${_action}?` +
|
||||
`park_id=${encodeURIComponent(park_id)}` +
|
||||
`&user_category_id=${encodeURIComponent(user_category_id)}` +
|
||||
`&price_parkplaceid=${encodeURIComponent(price_parkplaceid)}` +
|
||||
`&prine_name=${encodeURIComponent(prine_name)}` +
|
||||
`&ptype_id=${encodeURIComponent(ptype_id)}` +
|
||||
`&psection_id=${encodeURIComponent(psection_id)}` +
|
||||
`&pplace_id=${encodeURIComponent(pplace_id)}` +
|
||||
`&sort=${encodeURIComponent(sort)}` +
|
||||
`&sort_type=${encodeURIComponent(sort_type)}` +
|
||||
`&isExport=1`;
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'いいえ'
|
||||
}
|
||||
$('input[name="sort"]').val(sort);
|
||||
$('input[name="sort_type"]').val(newType);
|
||||
$('#list-form').submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
|
||||
|
||||
@ -1,18 +1,4 @@
|
||||
<!-- {{-- フラッシュメッセージ --}}
|
||||
@if(session('success'))
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@elseif(session('error'))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
{!! session('error') !!}
|
||||
</div>
|
||||
@endif -->
|
||||
|
||||
|
||||
{{-- アラート --}}
|
||||
{{-- アラート --}}
|
||||
@if(Session::has('success'))
|
||||
<div class="alert alert-success alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
@ -47,7 +33,7 @@
|
||||
|
||||
{{-- 編集マスタ --}}
|
||||
<div class="form-group col-3">
|
||||
<label>編集マスタ</label>
|
||||
<label class="required">編集マスタ</label>
|
||||
</div>
|
||||
<div class="form-group col-9 d-flex align-items-center">
|
||||
@php
|
||||
@ -77,7 +63,7 @@
|
||||
|
||||
{{-- ウェブ参照マスタ --}}
|
||||
<div class="form-group col-3">
|
||||
<label>ウェブ参照マスタ</label>
|
||||
<label class="required">ウェブ参照マスタ</label>
|
||||
</div>
|
||||
<div class="form-group col-9 d-flex align-items-center">
|
||||
@php
|
||||
@ -104,12 +90,12 @@
|
||||
|
||||
{{-- ウェブ参照マスタ自動切り替え日時 --}}
|
||||
<div class="form-group col-3">
|
||||
<label>ウェブ参照マスタ自動切り替え日時</label>
|
||||
<label class="required">ウェブ参照マスタ自動切り替え日時</label>
|
||||
</div>
|
||||
<div class="form-group col-9">
|
||||
<input type="datetime-local" name="auto_change_date"
|
||||
value="{{ old('auto_change_date', optional($setting->auto_change_date ?? null)->format('Y-m-d\TH:i')) }}"
|
||||
class="form-control form-control-lg">
|
||||
class="form-control form-control-lg" required>
|
||||
</div>
|
||||
|
||||
{{-- 自動切換えウェブ参照マスタ --}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user