krgm.so-manager-dev.com/app/Http/Requests/UserRequest.php
SongSong cf95babf8e
All checks were successful
Deploy previews (main_*) / preview (push) Successful in 10s
SWA-63駐輪車室マスタ作成
2025-08-21 20:50:27 +09:00

71 lines
3.1 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserRequest extends FormRequest
{
/**
* ユーザーがこのリクエストを実行する権限があるかどうかを判断
*/
public function authorize(): bool
{
return true; // 認証済みユーザーのみアクセス可能
}
/**
* リクエストに適用されるバリデーションルール
*/
public function rules(): array
{
return [
'user_id' => 'required|string|max:255',
'user_name' => 'required|string|max:255',
'user_phonetic' => 'nullable|string|max:255',
'user_gender' => 'nullable|string',
'user_birthdate' => 'nullable|date',
'user_mobile' => 'nullable|string|max:20',
'user_homephone' => 'nullable|string|max:20',
'user_primemail' => 'nullable|email|max:255',
'user_submail' => 'nullable|email|max:255',
'user_regident_zip' => 'nullable|string|max:10',
'user_regident_pre' => 'nullable|string|max:50',
'user_regident_city' => 'nullable|string|max:100',
'user_regident_add' => 'nullable|string|max:255',
'user_relate_zip' => 'nullable|string|max:10',
'user_relate_pre' => 'nullable|string|max:50',
'user_relate_city' => 'nullable|string|max:100',
'user_relate_add' => 'nullable|string|max:255',
'user_workplace' => 'nullable|string|max:255',
'user_school' => 'nullable|string|max:255',
'user_graduate' => 'nullable|string|max:255',
'user_idcard' => 'nullable|string|max:255',
'user_remarks' => 'nullable|string',
'photo_filename1' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
'photo_filename2' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
];
}
/**
* カスタムバリデーションメッセージ
*/
public function messages(): array
{
return [
'user_id.required' => '利用者IDは必須です。',
'user_id.unique' => 'この利用者IDは既に使用されています。',
'user_name.required' => '利用者名は必須です。',
'user_primemail.email' => '有効なメールアドレスを入力してください。',
'user_submail.email' => '有効なメールアドレスを入力してください。',
'photo_filename1.image' => '写真ファイル1は画像である必要があります。',
'photo_filename1.max' => '写真ファイル1のサイズは2MB以下である必要があります。',
'photo_filename2.image' => '写真ファイル2は画像である必要があります。',
'photo_filename2.max' => '写真ファイル2のサイズは2MB以下である必要があります。',
'password.required' => 'パスワードは必須です。',
'password.min' => 'パスワードは6文字以上である必要があります。',
'password.confirmed' => 'パスワード確認が一致しません。',
];
}
}