Php 如何填写Laravel 5.2所需的至少两个字段

Php 如何填写Laravel 5.2所需的至少两个字段,php,mysql,laravel,validation,laravel-5.2,Php,Mysql,Laravel,Validation,Laravel 5.2,我现在正在做一个项目,我希望至少有两个我的社交媒体档案必须填写。但我无法做到这一点。 我有这个表格和这些字段 <form role="form" id="submit" class="p-md col-8"> <div class="form-group"> <label>Twitter</label> <div class="so

我现在正在做一个项目,我希望至少有两个我的社交媒体档案必须填写。但我无法做到这一点。 我有这个表格和这些字段

<form role="form" id="submit" class="p-md col-8">
                <div class="form-group">
                    <label>Twitter</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-twitter"></i>
                        <input type="text" name="twitter" class="form-control" placeholder="https://twitter.com/username" value="{{!empty($user->twitter)?$user->twitter:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Facebook</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-facebook"></i>
                        <input type="text" name="facebook" class="form-control" placeholder="https://www.facebook.com/username/" value="{{!empty($user->facebook)?$user->facebook:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Linkedin</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-linkedin"></i>
                        <input type="text" name="linkedin" class="form-control" placeholder="https://www.linkedin.com/in/username" value="{{!empty($user->linkedin)?$user->linkedin:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Google Plus</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-google-plus"></i>
                        <input type="text" name="google_plus" class="form-control" placeholder="https://plus.google.com/+UserName" value="{{!empty($user->google_plus)?$user->google_plus:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Github</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-github"></i>
                        <input type="text" name="github" class="form-control" placeholder="https://github.com/username" value="{{!empty($user->github)?$user->github:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Tumblr</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-google-plus"></i>
                        <input type="text" name="dribbble" class="form-control" placeholder="https://www.tumblr.com/" value="{{!empty($user->dribbble)?$user->dribbble:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Youtube</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-youtube"></i>
                        <input type="text" name="youtube" id="youtube" class="form-control" placeholder="https://www.youtube.com/user/username" value="{{!empty($user->youtube)?$user->youtube:''}}">
                    </div>
                </div>

                <div class="form-group">
                    <label>Flicker</label>
                    <div class="social-link-input">
                        <i class="icon fa fa-flickr"></i>
                        <input type="text" name="flicker" class="form-control" placeholder="https://www.flickr.com/people/username/" value="{{!empty($user->flicker)?$user->fliker:''}}">
                    </div>
                </div>

                <button type="submit" class="btn btn-info m-t">Save</button>
            </form>

我如何才能做到这一点。请帮助

制作您的社交档案和数组

<input type="text" name="social['twitter']" class="form-control" placeholder="https://twitter.com/username" value="{{!empty($user->twitter)?$user->twitter:''}}">
试试规则

min验证中的字段必须具有最小值。字符串、数字和文件的计算方式与
size
规则相同

对于数组,大小对应于数组的计数(来自
大小
规则说明)


我的控制器中没有验证方法。那么我如何才能只验证这一点呢。请看我的控制器@谢里夫更新了答案。。。我希望这就是你的意思,我的控制器中没有验证方法。那么我如何才能只验证这一点呢。请看我的控制器@Alexeymezenin阅读
<input type="text" name="social['twitter']" class="form-control" placeholder="https://twitter.com/username" value="{{!empty($user->twitter)?$user->twitter:''}}">
$rules = ['social' => 'min:2']
$validator = \Validator::make($request->all(), $rules);
if($validator->fails()) return response()->json($validator->errors(), 422);