Laravel - 登录消息

我目前正在开发 Laravel 5.8 版本,并且正在使用 Laravel make:auth 选项。这创造了我的登录和注册,我所做的就是添加一个电话号码。所以这就是它在我的register.blade.php:


@extends('layouts.app')


@section('content')

<div class="container">

    <div class="row justify-content-center">

        <div class="col-md-8">

            <div class="card">

                <div class="card-header">{{ __('Register') }}</div>


                <div class="card-body">

                    <form method="POST" action="{{ route('register') }}">

                        @csrf


                        <div class="form-group row">

                            <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>


                            <div class="col-md-6">

                                <input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>


                                @error('name')

                                    <span class="invalid-feedback" role="alert">

                                        <strong>{{ $message }}</strong>

                                    </span>

                                @enderror

                            </div>

                        </div>


如果电子邮件已被接收,则向我显示跨度消息。那么我该如何@error('phone')为我的手机做到这一点呢?RegisterController.php我在我的手机中编码了我的身份unique:users?请帮我处理这个@error消息!


素胚勾勒不出你
浏览 133回答 2
2回答

小怪兽爱吃肉

这将检查用户电话号码,如电子邮件。它将分配唯一的用户电话号码protected function validator(array $data)&nbsp; {&nbsp; &nbsp;return Validator::make($data, [&nbsp; &nbsp; &nbsp; &nbsp; 'name' => 'required|string|max:255',&nbsp; &nbsp; &nbsp; &nbsp; 'email' => 'required|string|email|max:255|unique:users',&nbsp; &nbsp; &nbsp; &nbsp; 'password' => 'required|string|min:6|confirmed',&nbsp; &nbsp; &nbsp; &nbsp; 'phone' => 'required|unique:users,phone'&nbsp; &nbsp; ]);}用于在套准刀片中显示错误@error('phone')<span class="invalid-feedback" role="alert">&nbsp; &nbsp;<strong>{{ $message }}</strong></span>@enderror

有只小跳蛙

您需要将这样的内容添加到 RegisterController.phpprotected function validator(array $data){&nbsp; &nbsp; return Validator::make($data, [&nbsp; &nbsp; &nbsp; &nbsp; 'name' => 'required|string|max:255',&nbsp; &nbsp; &nbsp; &nbsp; 'email' => 'required|string|email|max:255|unique:users',&nbsp; &nbsp; &nbsp; &nbsp; 'password' => 'required|string|min:6|confirmed',&nbsp; &nbsp; &nbsp; &nbsp; 'phone' => 'required'&nbsp; &nbsp; ]);}
打开App,查看更多内容
随时随地看视频慕课网APP