如何在注册页面laravel中添加新输入? [英] How to add new input in register page laravel?

查看:50
本文介绍了如何在注册页面laravel中添加新输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Laravel 的注册页面上添加一个新字段来存储新的我数据库中的数据.基本上还在学习 Laravel,我是新手.我需要这方面的帮助,谢谢

I want to add a new field on Laravel's register page that's store the new data in my database. still learning Laravel so basically, i am a newbie. I need help on this, Thank you

推荐答案

就像在数据库和表单中添加一个新字段一样简单.在进入 Laravel 之前,先阅读它的基本文档.

It is simple as adding a new field in database and form. Go through the basic documentation of Laravel before jumping into it.

基本上,请按照以下步骤操作:

Basically, follow these steps:

1) 向您的数据库表中添加一个新列(即:'users' 表)

1) Add a new column to your database table (ie: 'users' table)

ALTER TABLE `users` ADD `address` TEXT NOT NULL AFTER `name`;

(这只是为基本用户添加字段的原始格式,添加字段的最佳方法是使用 laravel 迁移)

2) 向注册表单页面添加输入字段 (register.blade.php)

2) Add an input field to registration form page (register.blade.php)

<input id="address" type="text" class="form-control" name="address" value="{{ old('address') }}" required>

3) 更改您的 RegisterController.php

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

这篇关于如何在注册页面laravel中添加新输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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