mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Refringe
2cca45bcea
Part of moving back to PHPStan level 5 means we can remove some of these. They're very busy and don't give enough context to outweigh the ugly.
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Profile;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
|
use Laravel\Jetstream\Http\Livewire\UpdateProfileInformationForm;
|
|
use Livewire\Features\SupportRedirects\Redirector;
|
|
|
|
class UpdateProfileForm extends UpdateProfileInformationForm
|
|
{
|
|
/**
|
|
* The new cover photo for the user.
|
|
*/
|
|
public $cover;
|
|
|
|
/**
|
|
* When the photo is temporarily uploaded.
|
|
*/
|
|
public function updatedPhoto(): void
|
|
{
|
|
$this->validate([
|
|
'photo' => 'image|mimes:jpg,jpeg,png|max:1024', // 1MB Max
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* When the cover is temporarily uploaded.
|
|
*/
|
|
public function updatedCover(): void
|
|
{
|
|
$this->validate([
|
|
'cover' => 'image|mimes:jpg,jpeg,png|max:2048', // 2MB Max
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update the user's profile information.
|
|
*/
|
|
public function updateProfileInformation(UpdatesUserProfileInformation $updater): RedirectResponse|Redirector|null
|
|
{
|
|
$this->resetErrorBag();
|
|
|
|
$updater->update(
|
|
Auth::user(),
|
|
$this->photo || $this->cover
|
|
? array_merge($this->state, array_filter([
|
|
'photo' => $this->photo,
|
|
'cover' => $this->cover,
|
|
])) : $this->state
|
|
);
|
|
|
|
if (isset($this->photo) || isset($this->cover)) {
|
|
return redirect()->route('profile.show');
|
|
}
|
|
|
|
$this->dispatch('saved');
|
|
|
|
$this->dispatch('refresh-navigation-menu');
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Delete user's profile photo.
|
|
*/
|
|
public function deleteCoverPhoto(): void
|
|
{
|
|
Auth::user()->deleteCoverPhoto();
|
|
|
|
$this->dispatch('refresh-navigation-menu');
|
|
}
|
|
}
|