如何在表单寄存器(laravel generator infyom)中添加一些文本字段? [英] How to add some textfield in form register (laravel generator infyom)?

查看:64
本文介绍了如何在表单寄存器(laravel generator infyom)中添加一些文本字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里阅读了该教程: http://labs.infyom.com/laravelgenerator /docs/5.3/installation

I read the tutorial here : http://labs.infyom.com/laravelgenerator/docs/5.3/installation

我克隆了管理生成器: https://github.com/InfyOmLabs/adminlte-generator/tree/5.3

I clone the admin lte generator : https://github.com/InfyOmLabs/adminlte-generator/tree/5.3

我在本地主机中访问它.这样的注册表单: https://postimg.org/image/5gswtx4gn/

I access it in my localhost. The register form like this : https://postimg.org/image/5gswtx4gn/

我想添加一些文本字段和组合框.例如级别,级别,用户名等

I want to add some text field and combo box. eg, level, level, username etc

当我访问代码时,我很困惑 代码是这样的:

When I access the code, I'm confused The code is like this :

控制器寄存器是这样的:

Controller register is like this :

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
    use RegistersUsers;

    protected $redirectTo = '/home';

    public function __construct()
    {
        $this->middleware('guest');
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
        ]);
    }

    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
    }
}

它是供应商中的负载注册用户.就像这样:

It's load registeruser in vendor. It's like this :

<?php

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Events\Registered;

trait RegistersUsers
{
    use RedirectsUsers;

    public function showRegistrationForm()
    {
        return view('auth.register');
    }

    public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
            ?: redirect($this->redirectPath());
    }

    protected function guard()
    {
        return Auth::guard();
    }

    protected function registered(Request $request, $user)
    {
        //
    }
}

注册视图如下:

<div class="register-box-body">
    <p class="login-box-msg">Register a new membership</p>

    <form method="post" action="{{ url('/register') }}">

        {!! csrf_field() !!}

        <div class="form-group has-feedback{{ $errors->has('name') ? ' has-error' : '' }}">
            <input type="text" class="form-control" name="name" value="{{ old('name') }}" placeholder="Full Name">
            <span class="glyphicon glyphicon-user form-control-feedback"></span>

            @if ($errors->has('name'))
                <span class="help-block">
                    <strong>{{ $errors->first('name') }}</strong>
                </span>
            @endif
        </div>

        <div class="form-group has-feedback{{ $errors->has('email') ? ' has-error' : '' }}">
            <input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email">
            <span class="glyphicon glyphicon-envelope form-control-feedback"></span>

            @if ($errors->has('email'))
                <span class="help-block">
                    <strong>{{ $errors->first('email') }}</strong>
                </span>
            @endif
        </div>

        <div class="form-group has-feedback{{ $errors->has('password') ? ' has-error' : '' }}">
            <input type="password" class="form-control" name="password" placeholder="Password">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>

            @if ($errors->has('password'))
                <span class="help-block">
                    <strong>{{ $errors->first('password') }}</strong>
                </span>
            @endif
        </div>

        <div class="form-group has-feedback{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
            <input type="password" name="password_confirmation" class="form-control" placeholder="Confirm password">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>

            @if ($errors->has('password_confirmation'))
                <span class="help-block">
                    <strong>{{ $errors->first('password_confirmation') }}</strong>
                </span>
            @endif
        </div>

        <div class="row">
            <div class="col-xs-8">
                <div class="checkbox icheck">
                    <label>
                        <input type="checkbox"> I agree to the <a href="#">terms</a>
                    </label>
                </div>
            </div>
            <!-- /.col -->
            <div class="col-xs-4">
                <button type="submit" class="btn btn-primary btn-block btn-flat">Register</button>
            </div>
            <!-- /.col -->
        </div>
    </form>

    <a href="{{ url('/login') }}" class="text-center">I already have a membership</a>
</div>

我想问一下,如何在表格上添加文本字段和组合框进行注册?我很迷惑.因为注册视图是从供应商(Illuminate \ Foundation \ Auth \ RegistersUsers)调用的

I want to ask, how do I add a text field and a combo box on the form to register? I am confused. because the register view called from vendor(Illuminate\Foundation\Auth\RegistersUsers)

推荐答案

如果由于您使用的是正式的laravel auth,想要在注册过程中添加一些自定义字段,则可以在以下字段中添加字段:/resources/views/auth/register.blade.php

If you want to add some custom field to your registration process because your are using official laravel auth you can add your fields in : /resources/views/auth/register.blade.php

,然后您可以验证输入内容并将其保存在/app/Http/Controllers/Auth/RegisterController.php

and then you can validate and save your inputs in : /app/Http/Controllers/Auth/RegisterController.php

您无需在供应商中向注册用户添加任何内容,因为在每次安装或更新作曲家之后,添加的所有内容都会更改和替换.

you don't need to add anything to registeruser in vendor because every thing you add will change and replaced after every composer install or update.

这篇关于如何在表单寄存器(laravel generator infyom)中添加一些文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆