このページの2つのバージョン間の差分を表示します。
|
プログラム言語:php:laravel:バリデーション:requiredifを使って新規登録の場合のみ必須チェックを行う [2021/02/25 18:45] humolife 作成 |
プログラム言語:php:laravel:バリデーション:requiredifを使って新規登録の場合のみ必須チェックを行う [2021/02/25 18:48] (現在) humolife |
||
|---|---|---|---|
| 行 36: | 行 36: | ||
| // パスワードの入力があった場合のみ暗号化して保存 | // パスワードの入力があった場合のみ暗号化して保存 | ||
| - | if (!is_null($request-> | + | if (!is_null($request-> |
| + | | ||
| + | | ||
| $user-> | $user-> | ||
| } | } | ||
| 行 57: | 行 59: | ||
| class UserRequest extends FormRequest | class UserRequest extends FormRequest | ||
| { | { | ||
| - | /** | ||
| - | * Determine if the user is authorized to make this request. | ||
| - | * | ||
| - | * @return bool | ||
| - | */ | ||
| public function authorize() | public function authorize() | ||
| { | { | ||
| 行 67: | 行 64: | ||
| } | } | ||
| - | /** | ||
| - | * Get the validation rules that apply to the request. | ||
| - | * | ||
| - | * @return array | ||
| - | */ | ||
| public function rules() | public function rules() | ||
| { | { | ||
| 行 79: | 行 71: | ||
| ' | ' | ||
| ' | ' | ||
| + | // $this-> | ||
| Rule:: | Rule:: | ||
| ' | ' | ||