im new to laravel and am trying to add more fields to jetstreams profile page
in my appactionfortify
i have this
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
{
public function update(User $user, array $input): void
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'],
//user profiles
'language' => ['nullable', 'string', 'max:255']
])->validateWithBag('updateProfileInformation');
if (isset($input['photo'])) {
//$user->updateProfilePhoto($input['photo']);
$this->updateProfilePhoto($user, $input);
}
if ($input['email'] !== $user->email &&
$user instanceof MustVerifyEmail) {
$this->updateVerifiedUser($user, $input);
} else {
$user->forceFill([
'name' => $input['name'],
'email' => $input['email']
])->save();
//update / create profile
$user->profile()->updateOrCreate([],
[
'language' => $input['language'] ?? $user->profile->language,
]);
}
}
and in resourceviewprofileupdate-profile-information-from.blade.php
i added this
<!-- Language -->
<div class="mb-3">
<x-label for="language" class="form-label" value="{{ __('Language') }}" />
<select id="language" class="form-select {{ $errors->has('language') ? 'is-invalid' : '' }}"
wire:model.defer="state.language">
<option disabled>Select a language</option>
@foreach (config('app.available_locales') as $key => $language)
<option value="{{ $key }}"
{{ (auth()->user()->profile->language ?? config('app.locale')) === $key ? 'selected' : '' }}>
{{ $language }}</option>
@endforeach
</select>
<x-input-error for="language" />
</div>
this doesn’t save to db, and when i enter a language manually into db it doesn’t reflect in the view either. what am i missing here? thank you