meeting the requirements of a static analyzer

This commit is contained in:
Anatoliy Poloz
2024-01-15 17:11:55 +03:00
81 changed files with 1320 additions and 501 deletions

View File

@@ -2,47 +2,30 @@
namespace App\Livewire\Profile;
use App\Models\User;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
use Livewire\Component;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Livewire\WithFileUploads;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Contracts\View\View;
class PhotoForm extends Component
{
use WithFileUploads;
/**
* The component's state.
*
* @var array
*/
public $state = [];
public array $state = [];
/**
* The new avatar for the user.
*
* @var mixed
*/
public $photo;
public UploadedFile|string $photo = '';
public bool $isOnline = false;
public bool|int $isOnline = false;
/**
* User model
*
* @var \App\Models\User
*/
public $user;
public User $user;
/**
* Prepare the component.
*
* @return void
*/
public function mount()
public function mount(): void
{
$this->state = $this->user->withoutRelations()->toArray();
@@ -58,12 +41,7 @@ class PhotoForm extends Component
$this->isOnline = now()->unix() - $lastActivity < 150;
}
/**
* Update the user's profile information.
*
* @return void
*/
public function updateProfileInformation(UpdatesUserProfileInformation $updater)
public function updateProfileInformation(UpdatesUserProfileInformation $updater): void
{
$this->resetErrorBag();
@@ -77,31 +55,21 @@ class PhotoForm extends Component
$this->dispatch('saved');
}
public function updatedPhoto(mixed $newPhoto): void
public function updatedPhoto(TemporaryUploadedFile $newPhoto): void
{
Auth::user()->updateProfilePhoto($newPhoto);
$this->dispatch('saved');
}
/**
* Delete user's profile photo.
*
* @return void
*/
public function deleteProfilePhoto()
public function deleteProfilePhoto(): void
{
Auth::user()->deleteProfilePhoto();
$this->dispatch('refresh-navigation-menu');
}
/**
* Get the current user of the application.
*
* @return mixed
*/
public function getUserProperty()
public function getUserProperty(): User
{
return $this->user;
}