Ad

Fill Extra Column For User

- 1 answer

I have a user table with a referral column and this code in controller/auth:

protected function create(array $data)
    {

        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'referral' => md5($data['email']),
            ]);
    }

It adds a name, email and password but not referral.

There is no error or notice. What should I do to fill also referral column?

Ad

Answer

Open your User model (probably app/User.php, and change:

protected $fillable = [
        'name', 'email', 'password',
    ];

into

protected $fillable = [
        'name', 'email', 'password', 'referral'
    ];

You need to add column to fillable to save it.

Ad
source: stackoverflow.com
Ad