Extend or implement the class an example in this post: https://laracasts.com/discuss/channels/laravel/version-8-redirects
JetStream Profile Management - UpdateProfileInformationForm.php
Hello! There is a very interesting class in JetStream - UpdateProfileInformationForm which is situated at vendor folder. I can't edit it, I know, but there are two things, that I want to change in it. At this function:
public function updateProfileInformation(UpdatesUserProfileInformation $updater)
{
$this->resetErrorBag();
$updater->update(
Auth::user(),
$this->photo
? array_merge($this->state, ['photo' => $this->photo])
: $this->state
);
if (isset($this->photo)) {
return redirect()->route('profile.show');
}
$this->emit('saved');
$this->emit('refresh-navigation-dropdown');
}
If a user do something with a photo, it is redirected, and I can no longer reach the events that go further, what I need. All I want to do, is to remove this block of code:
if (isset($this->photo)) {
return redirect()->route('profile.show');
}
What is the best way to do it?
The second thing is that I want to add a property to this class, for example to do this:
<livewire:profile.update-profile-information-form :title="$title"/>
I think the solution should be the same as for the first question....
You're right @fanisa
That need some additional steps.
- First, create a
Livewirefolder insideapp\Http\if you don't already have one - Create a
UpdateProfileInformationForm.phpinside that newLivewirefolder - Copy the content of the vendor file:
\vendor\laravel\jetstream\src\Http\Livewire\UpdateProfileInformationForm.php - In the
bootmethod of yourJetstreamServiceProvideradd the following:
Livewire::component('profile.update-profile-information-form', UpdateProfileInformationForm::class);
Don't forget to use your version of the class at the top of the JetstreamServiceProvider
use App\Http\Livewire\UpdateProfileInformationForm;
Now you can customize your version of UpdateProfileInformationForm to your needs.
Please let me know if it doesn't work so I can see what else have I done to make this work in the past.
Please or to participate in this conversation.