Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have issue in creating admin user for Voyager Admin panel package in Laravel 5.4

after voyage package installation with this command :

php artisan voyager:install

I needed to create admin user with this command :

php artisan voyager:admin [email protected] --create

and then entering the name and the password

The problem is after entering the username and the password it's returning this error

General error: 1364 Field 'employee_name' doesn't have a default value (SQL: insert into employee (email) values ([email protected]))

and I have already a database but with different naming convention for example: the users table I call it employee and the name field called employee_name

My question is , is there any way to map the expected fields in voyager with my actual fields in my database because I can't change them ?

Thanks in advance .

like image 420
Ali Beshir Avatar asked Jan 09 '18 16:01

Ali Beshir


1 Answers

Since you altered the normal structure of the User model and will likely run into similar issues with other packages that try to add users, you could create a boot() method in the user model to set this->employee_name to this->name and then unset this->name so that when records from other packages try to use the name attribute you correct it to the employee_name attribute.

This is off the top of my head based on memory so it may involve a bit more 'logic' but I think if you look into the boot method you will see that you can do this type of thing. I have used it to autofill columns with dynamically based values.

HTH

like image 107
StevenHill Avatar answered Oct 28 '22 04:10

StevenHill