I'm currently trying to get Nova to play nice with my existing website and existing users table.
My issue is with the Gravatar. I already have an avatar field in my users table and would like to display those rather the auto generated Gravatars.
In my Nova/User class I have the following. (Also changed to first_name and last_name)
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Gravatar::make('Avatar'),
Text::make('First Name')
->sortable()
->rules('required', 'max:255'),
Text::make('Last Name')
->sortable()
->rules('required', 'max:255'),
Text::make('Email')
->sortable()
->rules('required', 'email', 'max:254')
->creationRules('unique:users,email')
->updateRules('unique:users,email,{{resourceId}}'),
Password::make('Password')
->onlyOnForms()
->creationRules('required', 'string', 'min:8')
->updateRules('nullable', 'string', 'min:8'),
];
}
When a user registers normally via the registration form, I'm doing the following with the avatar column from my auth > register controller. (I want to do the same in the Nova User Create)
RegisterController.php
protected function create(array $data)
{
$hash = md5(strtolower(trim($data['email'])));
$gravatar = 'http://www.gravatar.com/avatar/'.$hash.'??s=200&d=identicon';
$user = User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'avatar' => $gravatar, // user DB `avatar` is set to a default image (default-avatar.png)
'role_id' => '0', // DB is set to default 0
]);
}
- When I create a new user Via Nova, where/what is the form request that it is hitting?
- Where can I change the Nova/User view to display my avatars from my users database?