liberu-genealogy / genealogy-laravel

Full genealogy application using Laravel 11, PHP 8.3, Filament 3.2 and Livewire 3.5
https://www.liberu.net
MIT License
123 stars 57 forks source link

Sweep: Refactor and fix syntax errors on app/Filament/Pages/EditProfile.php #703

Closed curtisdelicata closed 5 months ago

sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #704

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Relevant files (click to expand). Mentioned files will always appear here. https://github.com/liberu-genealogy/genealogy-laravel/blob/ae71ccf6b872b45659325cffb338fcd365a5e56d/app/Filament/Pages/EditProfile.php#L1-L60 https://github.com/liberu-genealogy/genealogy-laravel/blob/ae71ccf6b872b45659325cffb338fcd365a5e56d/app/Filament/Pages/UpdateProfileInformationPage.php#L1-L69 https://github.com/liberu-genealogy/genealogy-laravel/blob/ae71ccf6b872b45659325cffb338fcd365a5e56d/app/Filament/Pages/UpdateProfileInformationPage.php#L1-L69 https://github.com/liberu-genealogy/genealogy-laravel/blob/ae71ccf6b872b45659325cffb338fcd365a5e56d/app/Http/Livewire/EditProfile.php#L1-L43

Step 2: ⌨️ Coding

app/Filament/Pages/EditProfile.php

Remove the unused `$name` and `$email` properties from the `EditProfile` class.
--- 
+++ 
@@ -1,11 +1,8 @@
 public User $user;
-
-public $name = '';
-public $email = '';

 public function mount()
 {
-    $this->user = Filament::auth()->user();
+    $this->user = Auth::user();
     $this->form->fill([
         'name' => $this->user->name,
         'email' => $this->user->email,

app/Filament/Pages/EditProfile.php

Update the `submit()` method to use the form state to retrieve the updated user information.
--- 
+++ 
@@ -2,9 +2,11 @@
 {
     $this->validate();

+    $state = $this->form->getState();
+
     $this->user->forceFill([
-        'name' => $this->name,
-        'email' => $this->email,
+        'name' => $state['name'],
+        'email' => $state['email'],
     ])->save();

     Filament::notify('success', 'Your profile has been updated.');

app/Filament/Pages/EditProfile.php

Remove the unused `Hash` import statement.
--- 
+++ 
@@ -2,4 +2,4 @@
 use Filament\Facades\Filament;
 use Filament\Forms\Components\TextInput;
 use Filament\Pages\Page;
-use Illuminate\Support\Facades\Hash;
+use Illuminate\Support\Facades\Auth;

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/refactor_and_fix_syntax_errors_on_appfil. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.