Compare commits
No commits in common. "e13302475e01ee9eae0996ac7f9e0481738e005e" and "ca283fc9a9efc7192dac1b4ee38acf30d4232805" have entirely different histories.
e13302475e
...
ca283fc9a9
@ -82,16 +82,21 @@ class RegularContractCreateController extends Controller
|
||||
// 並び替えパラメータ取得
|
||||
$sort = request()->input('sort', 'park_id');
|
||||
$order = request()->input('order', 'asc');
|
||||
\Log::info('sort param: ' . $sort);
|
||||
$sortable = [
|
||||
'park_ruby' => 'park.park_ruby',
|
||||
'city_id' => 'city.city_id',
|
||||
'station_name_ruby' => 'station.station_name_ruby',
|
||||
'park_id' => 'park.park_id',
|
||||
];
|
||||
$query->orderBy('park.park_id', 'asc');
|
||||
if (isset($sortable[$sort])) {
|
||||
$query->orderBy($sortable[$sort], $order);
|
||||
} else {
|
||||
$query->orderBy('park.park_id', 'asc');
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
$parks_table = $query->get();
|
||||
$parks_table = $query->skip(($page - 1) * $perPage)->take($perPage)->get();
|
||||
|
||||
if ($sort === 'park_ruby' || $sort === 'station_name_ruby') {
|
||||
$collator = new \Collator('ja_JP');
|
||||
@ -102,15 +107,7 @@ class RegularContractCreateController extends Controller
|
||||
? $collator->compare($a_val, $b_val)
|
||||
: $collator->compare($b_val, $a_val);
|
||||
})->values();
|
||||
} else {
|
||||
// park_id, city_idなどはSQLのorderByで十分なので、ここでPHPソートは不要
|
||||
if (isset($sortable[$sort])) {
|
||||
$parks_table = $parks_table->sortBy($sort, SORT_REGULAR, $order === 'desc')->values();
|
||||
}
|
||||
}
|
||||
$page = request()->input('page', 1);
|
||||
$perPage = 10;
|
||||
$parks_table = $parks_table->slice(($page - 1) * $perPage, $perPage)->values();
|
||||
|
||||
// zoneテーブルデータを取得(psectionテーブルとJOINしてpsection_subjectも取得)
|
||||
$zones = DB::table('zone')
|
||||
@ -143,7 +140,7 @@ class RegularContractCreateController extends Controller
|
||||
}
|
||||
|
||||
return view('regular_contract.create', [
|
||||
'active_menu' => $active_menu, // この画面のID
|
||||
'active_menu' => $active_menu, // 画面ID
|
||||
'user_name' => $user ? $user->user_name : '', // ユーザー名(ヘッダー用)
|
||||
'cities' => $cities,
|
||||
'stations' => $stations,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user