Compare commits
2 Commits
c2332743a4
...
a7033c1d43
| Author | SHA1 | Date | |
|---|---|---|---|
| a7033c1d43 | |||
| 6d4d72e7c2 |
@ -86,27 +86,17 @@ class UserEditController extends Controller
|
|||||||
$in_grace = true;
|
$in_grace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 開始日 > 終了日:契約終了月の開始日~翌月の終了日
|
// 開始日 > 終了日:契約終了月の開始日~翌月の終了日
|
||||||
if ($start_day > $end_day && (int)$today_month === (int)$contract_month) {
|
if ($start_day > $end_day) {
|
||||||
$start_datetime = $contract_year . '-' . $contract_month . '-' . sprintf('%02d', $start_day) . ' ' . $start_time;
|
$start_datetime = $contract_year . '-' . $contract_month . '-' . sprintf('%02d', $start_day) . ' ' . $start_time;
|
||||||
$end_year = date('Y', strtotime($contract_periode . ' +1 month'));
|
$next_month_date = date('Y-m', strtotime($contract_year . '-' . $contract_month . '-01 +1 month'));
|
||||||
$end_month = date('m', strtotime($contract_periode . ' +1 month'));
|
$end_datetime = $next_month_date . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
||||||
$end_datetime = $end_year . '-' . $end_month . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
|
||||||
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
||||||
if (strtotime($today_datetime) >= strtotime($start_datetime) && strtotime($today_datetime) <= strtotime($end_datetime)) {
|
if (strtotime($today_datetime) >= strtotime($start_datetime) && strtotime($today_datetime) <= strtotime($end_datetime)) {
|
||||||
$in_grace = true;
|
$in_grace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 開始日 > 終了日:契約終了月の翌月の終了日(翌月分)
|
|
||||||
if ($start_day > $end_day && (int)$today_month === (int)date('m', strtotime($contract_periode . ' +1 month'))) {
|
|
||||||
$end_year = date('Y', strtotime($contract_periode . ' +1 month'));
|
|
||||||
$end_month = date('m', strtotime($contract_periode . ' +1 month'));
|
|
||||||
$end_datetime = $end_year . '-' . $end_month . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
|
||||||
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
|
||||||
if (strtotime($today_datetime) <= strtotime($end_datetime)) {
|
|
||||||
$in_grace = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($in_grace) {
|
if ($in_grace) {
|
||||||
$is_update_period = false; // 猶予期間も編集不可
|
$is_update_period = false; // 猶予期間も編集不可
|
||||||
@ -146,85 +136,6 @@ class UserEditController extends Controller
|
|||||||
}
|
}
|
||||||
$user = DB::table('user')->where('user_id', $user_id)->first();
|
$user = DB::table('user')->where('user_id', $user_id)->first();
|
||||||
|
|
||||||
// バリデーションルール
|
|
||||||
$rules = [
|
|
||||||
'user_gender' => ['nullable', Rule::in(['男性', '女性'])],
|
|
||||||
'user_regident_zip_1' => 'nullable|digits:3',
|
|
||||||
'user_regident_zip_2' => 'nullable|digits:4',
|
|
||||||
'user_regident_pre' => 'nullable|string|max:5',
|
|
||||||
'user_regident_city' => 'nullable|string|max:20',
|
|
||||||
'user_regident_add' => 'nullable|string|max:50',
|
|
||||||
'user_birthdate' => 'nullable|date',
|
|
||||||
'user_homephone.*' => 'nullable|digits_between:1,5',
|
|
||||||
'user_mobile.*' => 'nullable|digits_between:1,5',
|
|
||||||
'user_primemail' => 'required|email',
|
|
||||||
'user_primemail_confirmation' => 'required|same:user_primemail',
|
|
||||||
'user_submail' => 'nullable|email|different:user_primemail',
|
|
||||||
'user_category' => ['required', Rule::in(['一般', '学生'])],
|
|
||||||
'user_workplace' => 'nullable|string|max:50',
|
|
||||||
'user_school' => 'nullable|string|max:50',
|
|
||||||
'user_graduate' => 'nullable|date',
|
|
||||||
'user_relate_zip_1' => 'nullable|digits:3',
|
|
||||||
'user_relate_zip_2' => 'nullable|digits:4',
|
|
||||||
'user_relate_pre' => 'nullable|string|max:5',
|
|
||||||
'user_relate_city' => 'nullable|string|max:20',
|
|
||||||
'user_relate_add' => 'nullable|string|max:50',
|
|
||||||
'photo_filename1' => 'nullable|image|max:4096',
|
|
||||||
'photo_filename2' => 'nullable|image|max:4096',
|
|
||||||
'user_pass_new' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
'min:8',
|
|
||||||
'regex:/^[a-zA-Z0-9]+$/', // 半角英数字のみ
|
|
||||||
],
|
|
||||||
'user_pass_confirm' => 'nullable|same:user_pass_new',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 利用者区分による必須項目
|
|
||||||
if ($request->user_category == '学生') {
|
|
||||||
$rules['user_school'] = 'required|string|max:50';
|
|
||||||
$rules['user_graduate'] = 'required|date';
|
|
||||||
}
|
|
||||||
|
|
||||||
$messages = [
|
|
||||||
'user_gender.in' => '性別は「男性」または「女性」を選択してください。',
|
|
||||||
'user_regident_zip_1.digits' => '居住地の郵便番号(前半3桁)は3桁の数字で入力してください。',
|
|
||||||
'user_regident_zip_2.digits' => '居住地の郵便番号(後半4桁)は4桁の数字で入力してください。',
|
|
||||||
'user_regident_pre.max' => '居住地の都道府県は5文字以内で入力してください。',
|
|
||||||
'user_regident_city.max' => '居住地の市区町村は20文字以内で入力してください。',
|
|
||||||
'user_regident_add.max' => '居住地の住所は50文字以内で入力してください。',
|
|
||||||
'user_birthdate.date' => '生年月日は正しい日付で入力してください。',
|
|
||||||
'user_homephone.*.digits_between' => '自宅電話番号はそれぞれ1~5桁の数字で入力してください。',
|
|
||||||
'user_mobile.*.digits_between' => '携帯電話番号はそれぞれ1~5桁の数字で入力してください。',
|
|
||||||
'user_primemail.required' => 'メールアドレスは必須です。',
|
|
||||||
'user_primemail.email' => 'メールアドレスは正しい形式で入力してください。',
|
|
||||||
'user_primemail_confirmation.required' => 'メールアドレスの確認は必須です。',
|
|
||||||
'user_primemail_confirmation.same' => '「メールアドレス」と「メールアドレスの確認」が一致しません。',
|
|
||||||
'user_submail.email' => '予備メールアドレスは正しい形式で入力してください。',
|
|
||||||
'user_submail.different' => 'メールアドレスと予備メールアドレスに同じアドレスを入力できません。',
|
|
||||||
'user_category.required' => '利用者区分は必須です。',
|
|
||||||
'user_category.in' => '利用者区分の値が不正です。',
|
|
||||||
'user_workplace.max' => '勤務先は50文字以内で入力してください。',
|
|
||||||
'user_school.max' => '学校名は50文字以内で入力してください。',
|
|
||||||
'user_school.required' => '学校名は必須です。',
|
|
||||||
'user_graduate.required' => '卒業年月日は必須です。',
|
|
||||||
'user_graduate.date' => '卒業年月日は正しい日付で入力してください。',
|
|
||||||
'user_relate_zip_1.digits' => '関連先の郵便番号(前半3桁)は3桁の数字で入力してください。',
|
|
||||||
'user_relate_zip_2.digits' => '関連先の郵便番号(後半4桁)は4桁の数字で入力してください。',
|
|
||||||
'user_relate_pre.max' => '関連先の都道府県は5文字以内で入力してください。',
|
|
||||||
'user_relate_city.max' => '関連先の市区町村は20文字以内で入力してください。',
|
|
||||||
'user_relate_add.max' => '関連先の住所は50文字以内で入力してください。',
|
|
||||||
'photo_filename1.image' => '本人確認書類画像(おもて)は画像ファイルを選択してください。',
|
|
||||||
'photo_filename1.max' => '本人確認書類画像(おもて)は4MB以内でアップロードしてください。',
|
|
||||||
'photo_filename2.image' => '本人確認書類画像(ウラ)は画像ファイルを選択してください。',
|
|
||||||
'photo_filename2.max' => '本人確認書類画像(ウラ)は4MB以内でアップロードしてください。',
|
|
||||||
'user_pass_new.min' => '新しいパスワードは8文字以上で入力してください。',
|
|
||||||
'user_pass_new.regex' => '新しいパスワードは半角英数字のみで入力してください。',
|
|
||||||
'user_pass_confirm.same' => '「新しいパスワード」と「パスワードの確認」が一致しません。',
|
|
||||||
];
|
|
||||||
|
|
||||||
$validated = $request->validate($rules, $messages);
|
|
||||||
|
|
||||||
// 編集不可項目はDB値を優先
|
// 編集不可項目はDB値を優先
|
||||||
// 契約・更新期間判定(showと同じロジックを利用)
|
// 契約・更新期間判定(showと同じロジックを利用)
|
||||||
$contract = DB::table('regular_contract')
|
$contract = DB::table('regular_contract')
|
||||||
@ -279,27 +190,17 @@ class UserEditController extends Controller
|
|||||||
$in_grace = true;
|
$in_grace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 開始日 > 終了日:契約終了月の開始日~翌月の終了日
|
// 開始日 > 終了日:契約終了月の開始日~翌月の終了日
|
||||||
if ($start_day > $end_day && (int)$today_month === (int)$contract_month) {
|
if ($start_day > $end_day) {
|
||||||
$start_datetime = $contract_year . '-' . $contract_month . '-' . sprintf('%02d', $start_day) . ' ' . $start_time;
|
$start_datetime = $contract_year . '-' . $contract_month . '-' . sprintf('%02d', $start_day) . ' ' . $start_time;
|
||||||
$end_year = date('Y', strtotime($contract_periode . ' +1 month'));
|
$next_month_date = date('Y-m', strtotime($contract_year . '-' . $contract_month . '-01 +1 month'));
|
||||||
$end_month = date('m', strtotime($contract_periode . ' +1 month'));
|
$end_datetime = $next_month_date . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
||||||
$end_datetime = $end_year . '-' . $end_month . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
|
||||||
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
||||||
if (strtotime($today_datetime) >= strtotime($start_datetime) && strtotime($today_datetime) <= strtotime($end_datetime)) {
|
if (strtotime($today_datetime) >= strtotime($start_datetime) && strtotime($today_datetime) <= strtotime($end_datetime)) {
|
||||||
$in_grace = true;
|
$in_grace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 開始日 > 終了日:契約終了月の翌月の終了日(翌月分)
|
|
||||||
if ($start_day > $end_day && (int)$today_month === (int)date('m', strtotime($contract_periode . ' +1 month'))) {
|
|
||||||
$end_year = date('Y', strtotime($contract_periode . ' +1 month'));
|
|
||||||
$end_month = date('m', strtotime($contract_periode . ' +1 month'));
|
|
||||||
$end_datetime = $end_year . '-' . $end_month . '-' . sprintf('%02d', $end_day) . ' ' . $end_time;
|
|
||||||
$today_datetime = date('Y-m-d') . ' ' . $today_time;
|
|
||||||
if (strtotime($today_datetime) <= strtotime($end_datetime)) {
|
|
||||||
$in_grace = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($in_grace) {
|
if ($in_grace) {
|
||||||
$is_update_period = false; // 猶予期間も編集不可
|
$is_update_period = false; // 猶予期間も編集不可
|
||||||
@ -307,6 +208,202 @@ class UserEditController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// バリデーションルール
|
||||||
|
$rules = [
|
||||||
|
'user_gender' => ['nullable', Rule::in(['男性', '女性'])],
|
||||||
|
'user_regident_zip_1' => 'nullable|digits:3',
|
||||||
|
'user_regident_zip_2' => 'nullable|digits:4',
|
||||||
|
'user_regident_pre' => [
|
||||||
|
'nullable',
|
||||||
|
Rule::in([
|
||||||
|
'北海道',
|
||||||
|
'青森県',
|
||||||
|
'岩手県',
|
||||||
|
'宮城県',
|
||||||
|
'秋田県',
|
||||||
|
'山形県',
|
||||||
|
'福島県',
|
||||||
|
'茨城県',
|
||||||
|
'栃木県',
|
||||||
|
'群馬県',
|
||||||
|
'埼玉県',
|
||||||
|
'千葉県',
|
||||||
|
'東京都',
|
||||||
|
'神奈川県',
|
||||||
|
'新潟県',
|
||||||
|
'富山県',
|
||||||
|
'石川県',
|
||||||
|
'福井県',
|
||||||
|
'山梨県',
|
||||||
|
'長野県',
|
||||||
|
'岐阜県',
|
||||||
|
'静岡県',
|
||||||
|
'愛知県',
|
||||||
|
'三重県',
|
||||||
|
'滋賀県',
|
||||||
|
'京都府',
|
||||||
|
'大阪府',
|
||||||
|
'兵庫県',
|
||||||
|
'奈良県',
|
||||||
|
'和歌山県',
|
||||||
|
'鳥取県',
|
||||||
|
'島根県',
|
||||||
|
'岡山県',
|
||||||
|
'広島県',
|
||||||
|
'山口県',
|
||||||
|
'徳島県',
|
||||||
|
'香川県',
|
||||||
|
'愛媛県',
|
||||||
|
'高知県',
|
||||||
|
'福岡県',
|
||||||
|
'佐賀県',
|
||||||
|
'長崎県',
|
||||||
|
'熊本県',
|
||||||
|
'大分県',
|
||||||
|
'宮崎県',
|
||||||
|
'鹿児島県',
|
||||||
|
'沖縄県'
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
'user_regident_city' => ['nullable', 'string', 'max:20', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'user_regident_add' => ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'user_birthdate' => 'nullable|date',
|
||||||
|
'user_homephone.*' => 'nullable|digits_between:1,5',
|
||||||
|
'user_mobile.*' => 'nullable|digits_between:1,5',
|
||||||
|
'user_primemail' => 'required|email|max:80',
|
||||||
|
'user_primemail_confirmation' => 'required|same:user_primemail',
|
||||||
|
'user_submail' => 'nullable|email|different:user_primemail|max:80',
|
||||||
|
'user_category' => ['required', Rule::in(['一般', '学生'])],
|
||||||
|
'user_workplace' => ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'user_school' => ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'user_graduate' => 'nullable|date',
|
||||||
|
'user_relate_zip_1' => 'nullable|digits:3',
|
||||||
|
'user_relate_zip_2' => 'nullable|digits:4',
|
||||||
|
'user_relate_pre' => [
|
||||||
|
'nullable',
|
||||||
|
Rule::in([
|
||||||
|
'北海道',
|
||||||
|
'青森県',
|
||||||
|
'岩手県',
|
||||||
|
'宮城県',
|
||||||
|
'秋田県',
|
||||||
|
'山形県',
|
||||||
|
'福島県',
|
||||||
|
'茨城県',
|
||||||
|
'栃木県',
|
||||||
|
'群馬県',
|
||||||
|
'埼玉県',
|
||||||
|
'千葉県',
|
||||||
|
'東京都',
|
||||||
|
'神奈川県',
|
||||||
|
'新潟県',
|
||||||
|
'富山県',
|
||||||
|
'石川県',
|
||||||
|
'福井県',
|
||||||
|
'山梨県',
|
||||||
|
'長野県',
|
||||||
|
'岐阜県',
|
||||||
|
'静岡県',
|
||||||
|
'愛知県',
|
||||||
|
'三重県',
|
||||||
|
'滋賀県',
|
||||||
|
'京都府',
|
||||||
|
'大阪府',
|
||||||
|
'兵庫県',
|
||||||
|
'奈良県',
|
||||||
|
'和歌山県',
|
||||||
|
'鳥取県',
|
||||||
|
'島根県',
|
||||||
|
'岡山県',
|
||||||
|
'広島県',
|
||||||
|
'山口県',
|
||||||
|
'徳島県',
|
||||||
|
'香川県',
|
||||||
|
'愛媛県',
|
||||||
|
'高知県',
|
||||||
|
'福岡県',
|
||||||
|
'佐賀県',
|
||||||
|
'長崎県',
|
||||||
|
'熊本県',
|
||||||
|
'大分県',
|
||||||
|
'宮崎県',
|
||||||
|
'鹿児島県',
|
||||||
|
'沖縄県'
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
'user_relate_city' => ['nullable', 'string', 'max:20', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'user_relate_add' => ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'],
|
||||||
|
'photo_filename1' => 'nullable|image|max:4096',
|
||||||
|
'photo_filename2' => 'nullable|image|max:4096',
|
||||||
|
'user_pass_new' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'min:8',
|
||||||
|
'regex:/^[a-zA-Z0-9]+$/', // 半角英数字のみ
|
||||||
|
],
|
||||||
|
'user_pass_confirm' => 'nullable|same:user_pass_new',
|
||||||
|
];
|
||||||
|
|
||||||
|
// 利用者区分による必須項目
|
||||||
|
if ($request->user_category == '学生') {
|
||||||
|
$rules['user_school'] = 'required|string|max:50';
|
||||||
|
$rules['user_graduate'] = 'required|date';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 編集不可の場合は user_category, user_school, user_graduate の必須チェックを外す
|
||||||
|
if (!$is_update_period) {
|
||||||
|
$rules['user_category'] = ['nullable', Rule::in(['一般', '学生'])];
|
||||||
|
$rules['user_school'] = ['nullable', 'string', 'max:50', 'regex:/^(?:(?![\xF0-\xF7][\x80-\xBF]{3}).)*$/'];
|
||||||
|
$rules['user_graduate'] = 'nullable|date';
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = [
|
||||||
|
'user_gender.in' => '性別は「男性」または「女性」を選択してください。',
|
||||||
|
'user_regident_zip_1.digits' => '居住所の郵便番号(前半3桁)は3桁の数字で入力してください。',
|
||||||
|
'user_regident_zip_2.digits' => '居住所の郵便番号(後半4桁)は4桁の数字で入力してください。',
|
||||||
|
'user_regident_pre.in' => '都道府県は選択肢から選んでください。',
|
||||||
|
'user_regident_city.max' => '居住所の市区町村は20文字以内で入力してください。',
|
||||||
|
'user_regident_city.regex' => '居住所の市区町村に絵文字などの特殊文字は使用できません。',
|
||||||
|
'user_regident_add.max' => '居住所の住所は50文字以内で入力してください。',
|
||||||
|
'user_regident_add.regex' => '居住所の住所に絵文字などの特殊文字は使用できません。',
|
||||||
|
'user_birthdate.date' => '生年月日は正しい日付で入力してください。',
|
||||||
|
'user_homephone.*.digits_between' => '自宅電話番号はそれぞれ1~5桁の数字で入力してください。',
|
||||||
|
'user_mobile.*.digits_between' => '携帯電話番号はそれぞれ1~5桁の数字で入力してください。',
|
||||||
|
'user_primemail.required' => 'メールアドレスは必須です。',
|
||||||
|
'user_primemail.email' => 'メールアドレスは正しい形式で入力してください。',
|
||||||
|
'user_primemail.max' => 'メールアドレスは80文字以内で入力してください。',
|
||||||
|
'user_primemail_confirmation.required' => 'メールアドレスの確認は必須です。',
|
||||||
|
'user_primemail_confirmation.same' => '「メールアドレス」と「メールアドレスの確認」が一致しません。',
|
||||||
|
'user_submail.email' => '予備メールアドレスは正しい形式で入力してください。',
|
||||||
|
'user_submail.max' => '予備メールアドレスは80文字以内で入力してください。',
|
||||||
|
'user_submail.different' => 'メールアドレスと予備メールアドレスに同じアドレスを入力できません。',
|
||||||
|
'user_category.required' => '利用者区分は必須です。',
|
||||||
|
'user_category.in' => '利用者区分の値が不正です。',
|
||||||
|
'user_workplace.max' => '勤務先は50文字以内で入力してください。',
|
||||||
|
'user_workplace.regex' => '勤務先に絵文字などの特殊文字は使用できません。',
|
||||||
|
'user_school.max' => '学校名は50文字以内で入力してください。',
|
||||||
|
'user_school.required' => '学校名は必須です。',
|
||||||
|
'user_school.regex' => '学校名に絵文字などの特殊文字は使用できません。',
|
||||||
|
'user_graduate.required' => '卒業年月日は必須です。',
|
||||||
|
'user_graduate.date' => '卒業年月日は正しい日付で入力してください。',
|
||||||
|
'user_relate_zip_1.digits' => '住所の郵便番号(前半3桁)は3桁の数字で入力してください。',
|
||||||
|
'user_relate_zip_2.digits' => '住所の郵便番号(後半4桁)は4桁の数字で入力してください。',
|
||||||
|
'user_relate_pre.in' => '住所の都道府県は選択肢から選んでください。',
|
||||||
|
'user_relate_city.max' => '住所の市区町村は20文字以内で入力してください。',
|
||||||
|
'user_relate_city.regex' => '住所の市区町村に絵文字などの特殊文字は使用できません。',
|
||||||
|
'user_relate_add.max' => '住所は50文字以内で入力してください。',
|
||||||
|
'user_relate_add.regex' => '住所に絵文字などの特殊文字は使用できません。',
|
||||||
|
'photo_filename1.image' => '本人確認書類画像(おもて)は画像ファイルを選択してください。',
|
||||||
|
'photo_filename1.max' => '本人確認書類画像(おもて)は4MB以内でアップロードしてください。',
|
||||||
|
'photo_filename2.image' => '本人確認書類画像(ウラ)は画像ファイルを選択してください。',
|
||||||
|
'photo_filename2.max' => '本人確認書類画像(ウラ)は4MB以内でアップロードしてください。',
|
||||||
|
'user_pass_new.min' => '新しいパスワードは8文字以上で入力してください。',
|
||||||
|
'user_pass_new.regex' => '新しいパスワードは半角英数字のみで入力してください。',
|
||||||
|
'user_pass_confirm.same' => '「新しいパスワード」と「パスワードの確認」が一致しません。',
|
||||||
|
];
|
||||||
|
|
||||||
|
$validated = $request->validate($rules, $messages);
|
||||||
|
|
||||||
// 編集不可項目リスト
|
// 編集不可項目リスト
|
||||||
$readonly_fields = [
|
$readonly_fields = [
|
||||||
'user_regident_zip_1',
|
'user_regident_zip_1',
|
||||||
@ -321,14 +418,27 @@ class UserEditController extends Controller
|
|||||||
'user_category'
|
'user_category'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
if (!$is_update_period) {
|
if (!$is_update_period) {
|
||||||
// 編集不可項目はDB値を優先し、確認画面にも必ず渡す
|
|
||||||
foreach ($readonly_fields as $field) {
|
foreach ($readonly_fields as $field) {
|
||||||
if (property_exists($user, $field)) {
|
if ($field === 'user_category') {
|
||||||
|
// 利用者区分はusertypeテーブルから取得した文字列を渡す
|
||||||
|
$user_category = '';
|
||||||
|
if (isset($user->user_categoryid)) {
|
||||||
|
$usertype = DB::table('usertype')
|
||||||
|
->where('user_categoryid', $user->user_categoryid)
|
||||||
|
->first();
|
||||||
|
if ($usertype && isset($usertype->usertype_subject1)) {
|
||||||
|
$user_category = $usertype->usertype_subject1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$request->merge(['user_category' => $user_category]);
|
||||||
|
} else if (property_exists($user, $field)) {
|
||||||
$request->merge([$field => $user->$field]);
|
$request->merge([$field => $user->$field]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 編集不可・可能どちらでも、セッションには最終的な値を保存
|
// 編集不可・可能どちらでも、セッションには最終的な値を保存
|
||||||
$request->flash();
|
$request->flash();
|
||||||
|
|
||||||
|
|||||||
@ -303,7 +303,7 @@
|
|||||||
<input type="submit" class="btn btn-lg btn-block btn-success" value="入力内容を確認する" />
|
<input type="submit" class="btn btn-lg btn-block btn-success" value="入力内容を確認する" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-5 mt10">
|
<div class="col-12 col-md-5 mt10">
|
||||||
<a class="btn btn-lg btn-block btn-outline-success" href="{{ url('/user/withdraw') }}">メニューへ戻る</a>
|
<a class="btn btn-lg btn-block btn-outline-success" href="{{ route('mypage') }}">メニューへ戻る</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
@ -364,8 +364,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
{{-- JSバリデーション(info.blade.phpの内容を参考に) --}}
|
|
||||||
<script>
|
<script>
|
||||||
|
var isUpdatePeriod = <?php echo json_encode($is_update_period); ?>;
|
||||||
document.querySelector('form').addEventListener('submit', function(e) {
|
document.querySelector('form').addEventListener('submit', function(e) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
// メールアドレスチェック
|
// メールアドレスチェック
|
||||||
@ -398,16 +398,16 @@
|
|||||||
if (!homeFilled && !mobileFilled) {
|
if (!homeFilled && !mobileFilled) {
|
||||||
errors.push('「自宅電話番号」と「携帯電話番号」のいずれかは入力してください。');
|
errors.push('「自宅電話番号」と「携帯電話番号」のいずれかは入力してください。');
|
||||||
}
|
}
|
||||||
// 利用者区分が学生の場合のみ、学校名と卒業予定が必須
|
// 利用者区分が学生の場合のみ、学校名と卒業予定が必須(編集可能時のみ)
|
||||||
var isStudent = document.getElementById('user_categoryid_gakusei').checked;
|
var isStudent = document.getElementById('user_categoryid_gakusei').checked;
|
||||||
if (isStudent) {
|
if (isUpdatePeriod && isStudent) {
|
||||||
var school = document.getElementById('user_school').value.trim();
|
var school = document.getElementById('user_school').value.trim();
|
||||||
var graduate = document.getElementById('user_graduate').value.trim();
|
var graduate = document.getElementById('user_graduate').value.trim();
|
||||||
if (!school) {
|
if (!school) {
|
||||||
errors.push('「学校名」は必須です。(学生の場合)');
|
errors.push('「学校名」は必須です。');
|
||||||
}
|
}
|
||||||
if (!graduate) {
|
if (!graduate) {
|
||||||
errors.push('「卒業予定」は必須です。(学生の場合)');
|
errors.push('「卒業予定」は必須です。');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// パスワードバリデーション(8文字以上の半角英数字)
|
// パスワードバリデーション(8文字以上の半角英数字)
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
ご確認ください。</p>
|
ご確認ください。</p>
|
||||||
<p><u>確認メールのURLをクリックすると変更が完了します。</u></p>
|
<p><u>確認メールのURLをクリックすると変更が完了します。</u></p>
|
||||||
<div class="mt-4 mb-4 text-center">
|
<div class="mt-4 mb-4 text-center">
|
||||||
<a href="{{ route('user.info') }}" class="btn btn-lg btn-block btn-outline-success">マイページへ戻る</a>
|
<a href="{{ route('mypage') }}" class="btn btn-lg btn-block btn-outline-success">マイページへ戻る</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -20,6 +20,11 @@ Route::get('/', function () {
|
|||||||
return redirect()->route('login');
|
return redirect()->route('login');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/mypage', function () {
|
||||||
|
// 仮の表示(コントローラー未作成の場合)
|
||||||
|
return 'マイページ(仮)';
|
||||||
|
})->name('mypage');
|
||||||
|
|
||||||
// ユーザー情報確認画面
|
// ユーザー情報確認画面
|
||||||
Route::get('/user/info', [UserInfoController::class, 'show'])
|
Route::get('/user/info', [UserInfoController::class, 'show'])
|
||||||
->name('user.info');
|
->name('user.info');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user