diff --git a/README.md b/README.md index 5c720b6..aac23a1 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ protected $fillable = [ 'name', 'email', 'password', - 'avatar_url', + 'avatar_url', // or column name according to config('filament-edit-profile.avatar_column', 'avatar_url') ]; ``` @@ -162,7 +162,8 @@ class User extends Authenticatable implements HasAvatar // ... public function getFilamentAvatarUrl(): ?string { - return $this->avatar_url ? Storage::url("$this->avatar_url") : null; + $avatarColumn = config('filament-edit-profile.avatar_column', 'avatar_url'); + return $this->$avatarColumn ? Storage::url("$this->$avatarColumn") : null; } } ``` diff --git a/config/filament-edit-profile.php b/config/filament-edit-profile.php index e961079..cffcbb9 100644 --- a/config/filament-edit-profile.php +++ b/config/filament-edit-profile.php @@ -1,6 +1,7 @@ 'avatar_url', 'disk' => env('FILESYSTEM_DISK', 'public'), 'visibility' => 'public', // or replace by filesystem disk visibility with fallback value ]; diff --git a/database/migrations/add_avatar_url_to_users_table.php.stub b/database/migrations/add_avatar_url_to_users_table.php.stub index 60c5b48..5627ef3 100644 --- a/database/migrations/add_avatar_url_to_users_table.php.stub +++ b/database/migrations/add_avatar_url_to_users_table.php.stub @@ -12,7 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('users', function (Blueprint $table) { - $table->string('avatar_url')->nullable(); + $table->string(config('filament-edit-profile.avatar_column', 'avatar_url'))->nullable(); }); } @@ -22,7 +22,7 @@ return new class extends Migration public function down(): void { Schema::table('users', function (Blueprint $table) { - $table->dropColumn('avatar_url'); + $table->dropColumn(config('filament-edit-profile.avatar_column', 'avatar_url')); }); } }; diff --git a/src/Livewire/EditProfileForm.php b/src/Livewire/EditProfileForm.php index e8e28cd..6cbb184 100644 --- a/src/Livewire/EditProfileForm.php +++ b/src/Livewire/EditProfileForm.php @@ -28,7 +28,7 @@ public function mount(): void $this->userClass = get_class($this->user); - $this->form->fill($this->user->only('avatar_url', 'name', 'email')); + $this->form->fill($this->user->only(config('filament-edit-profile.avatar_column', 'avatar_url'), 'name', 'email')); } public function form(Form $form): Form @@ -39,7 +39,7 @@ public function form(Form $form): Form ->aside() ->description(__('filament-edit-profile::default.profile_information_description')) ->schema([ - FileUpload::make('avatar_url') + FileUpload::make(config('filament-edit-profile.avatar_column', 'avatar_url')) ->label(__('filament-edit-profile::default.avatar')) ->avatar() ->imageEditor()