133 lines
6.6 KiB
PHP
133 lines
6.6 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Http\Requests;
|
||
|
||
use Illuminate\Foundation\Http\FormRequest;
|
||
|
||
class ParkRequest extends FormRequest
|
||
{
|
||
public function authorize(): bool
|
||
{
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* add / edit 用的 validation
|
||
*/
|
||
public function rules(): array
|
||
{
|
||
if ($this->isMethod('post') || $this->isMethod('put')) {
|
||
return [
|
||
// 必須
|
||
'city_id' => ['required', 'integer'],
|
||
'park_name' => ['required', 'string', 'max:255'],
|
||
|
||
// 文字系
|
||
'park_ruby' => ['nullable', 'string', 'max:255'],
|
||
'park_syllabary' => ['nullable', 'string', 'max:3'],
|
||
'park_adrs' => ['nullable', 'string', 'max:255'],
|
||
'price_memo' => ['nullable', 'string', 'max:1000'],
|
||
|
||
// フラグ / 種別系(integer想定)
|
||
'park_close_flag' => ['nullable', 'integer'],
|
||
'inverse_use_flag1' => ['nullable', 'integer'], // 逆利用フラグ(一覧)
|
||
'inverse_use_flag2' => ['nullable', 'integer'], // 逆利用フラグ(学生)
|
||
'parking_regulations_flag' => ['nullable', 'integer'], // 駐輪規定フラグ
|
||
'alert_flag' => ['nullable', 'integer'], // 残警告チェックフラグ
|
||
'immediate_use_perm' => ['nullable', 'integer'], // 契約後即利用許可
|
||
'gender_display_flag' => ['nullable', 'integer'], // 項目表示設定:性別
|
||
'bd_display_flag' => ['nullable', 'integer'], // 項目表示設定:生年月日
|
||
'securityreg_display_flag' => ['nullable', 'integer'], // 項目表示設定:防犯登録番号
|
||
'park_fixed_contract' => ['nullable', 'integer'], // 駐輪場契約形態(定期)
|
||
'park_temporary_contract' => ['nullable', 'integer'], // 駐輪場契約形態(一時利用)
|
||
'park_available_time_flag' => ['nullable', 'integer'], // 利用可能時間制限フラグ
|
||
'park_manager_flag' => ['nullable', 'integer'], // 常駐管理人フラグ
|
||
'park_roof_flag' => ['nullable', 'integer'], // 屋根フラグ
|
||
'park_issuing_machine_flag' => ['nullable', 'integer'], // シール発行機フラグ
|
||
'reduction_guide_display_flag' => ['nullable', 'integer'], // 減免案内表示フラグ
|
||
'overyear_flag' => ['nullable', 'integer'], // 年跨ぎ
|
||
|
||
// 数値系
|
||
'print_number' => ['nullable', 'integer'], // 印字数
|
||
'distance_twopoints' => ['nullable', 'integer'], // 二点間距離
|
||
'reduction_age' => ['nullable', 'integer'], // 減免対象年齢
|
||
'reduction_guide_display_start_month' => ['nullable', 'integer'], // 減免案内表示開始月数
|
||
|
||
// 日付/時刻系(date/time/datetime)
|
||
'park_day' => ['nullable', 'date'], // 閉設日
|
||
'keep_alive' => ['nullable', 'date'], // 最新キープアライブ
|
||
'update_grace_period_start_date' => ['nullable', 'integer', 'between:1,31'], // 更新期間開始日
|
||
'update_grace_period_start_time' => ['nullable', 'date_format:H:i'], // 更新期間開始時
|
||
'update_grace_period_end_date' => ['nullable', 'integer', 'between:1,31'], // 更新期間終了日
|
||
'update_grace_period_end_time' => ['nullable', 'date_format:H:i'], // 更新期間終了時
|
||
'parking_start_grace_period' => ['nullable', 'integer', 'between:1,31'], // 駐輪開始猶予期間
|
||
|
||
'reminder_type' => ['nullable', 'integer'], // リマインダー種別
|
||
'reminder_time' => ['nullable', 'date_format:H:i'], // リマインダー時間
|
||
'park_available_time_from' => ['nullable', 'date_format:H:i'], // 利用可能時間(開始)
|
||
'park_available_time_to' => ['nullable', 'date_format:H:i'], // 利用可能時間(終了)
|
||
'park_manager_resident_from' => ['nullable', 'date_format:H:i'], // 常駐時間(開始)
|
||
'park_manager_resident_to' => ['nullable', 'date_format:H:i'], // 常駐時間(終了)
|
||
|
||
// 緯度/経度/電話など
|
||
'park_latitude' => ['nullable', 'string', 'max:50'], // 駐車場座標(緯度)
|
||
'park_longitude' => ['nullable', 'string', 'max:50'], // 駐車場座標(経度)
|
||
'park_tel' => ['nullable', 'string', 'max:50'], // 電話番号
|
||
|
||
// 備考/自由入力
|
||
'park_restriction' => ['nullable', 'string', 'max:50'], // 車種制限
|
||
'park_procedure' => ['nullable', 'string', 'max:50'], // 手続方法
|
||
'park_payment' => ['nullable', 'string', 'max:100'], // 支払方法
|
||
'park_using_method' => ['nullable', 'string', 'max:1000'], // 駐輪場利用方法
|
||
'park_contract_renewal_term' => ['nullable', 'string', 'max:255'], // 定期更新期間
|
||
'park_reservation' => ['nullable', 'string', 'max:255'], // 空き待ち予約
|
||
'park_reference' => ['nullable', 'string', 'max:1000'], // 特記事項
|
||
'student_id_confirmation_type' => ['nullable', 'string', 'max:255'], // 学生証確認種別
|
||
];
|
||
}
|
||
|
||
return [];
|
||
}
|
||
|
||
//
|
||
protected function prepareForValidation(): void
|
||
{
|
||
foreach ([
|
||
'park_available_time_from',
|
||
'park_available_time_to',
|
||
'park_manager_resident_from',
|
||
'park_manager_resident_to',
|
||
'update_grace_period_start_time',
|
||
'update_grace_period_end_time',
|
||
'reminder_time',
|
||
|
||
] as $key) {
|
||
if ($this->filled($key)) {
|
||
$v = (string) $this->input($key);
|
||
$this->merge([$key => substr($v, 0, 5)]); // HH:MM로 통일
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* add / edit payload
|
||
*/
|
||
public function payload(): array
|
||
{
|
||
return $this->validated();
|
||
}
|
||
|
||
public function filters(): array
|
||
{
|
||
return [
|
||
'park_name' => $this->input('park_name'),
|
||
'city_id' => $this->input('city_id'),
|
||
'sort' => $this->input('sort'),
|
||
'sort_type' => $this->input('sort_type', 'asc'),
|
||
];
|
||
}
|
||
|
||
|
||
}
|