- 🛠️ Replaced inline dashboard layout with Livewire component for better reusability and management.

- 🔒 Introduced Nostr-based login functionality with `nostr-tools` integration.
- 🖼️ Added user profile photo handling (upload, delete, and URL retrieval) in the `User` model.
- 💻 Updated views to use `flux:avatar` for consistent user avatars.
- ✂️ Removed unused routes and adjusted dashboard routing logic.
- 📦 Updated dependencies in `package.json` and `yarn.lock`.
This commit is contained in:
HolgerHatGarKeineNode
2025-11-21 12:05:31 +01:00
parent 01d35d8664
commit ddfa915acc
13 changed files with 393 additions and 67 deletions

View File

@@ -5,7 +5,9 @@ namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Http\UploadedFile;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use ParagonIE\CipherSweet\BlindIndex;
use ParagonIE\CipherSweet\EncryptedRow;
@@ -14,7 +16,7 @@ use Spatie\LaravelCipherSweet\Concerns\UsesCipherSweet;
use Spatie\LaravelCipherSweet\Contracts\CipherSweetEncrypted;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements MustVerifyEmail, CipherSweetEncrypted
class User extends Authenticatable implements CipherSweetEncrypted
{
use UsesCipherSweet;
use HasFactory;
@@ -101,4 +103,73 @@ class User extends Authenticatable implements MustVerifyEmail, CipherSweetEncryp
{
return $this->belongsToMany(LibraryItem::class, 'library_item_user', 'user_id', 'library_item_id');
}
public function updateProfilePhoto(UploadedFile $photo)
{
tap($this->profile_photo_path, function ($previous) use ($photo) {
$this->forceFill([
'profile_photo_path' => $photo->storePublicly(
'profile-photos', ['disk' => $this->profilePhotoDisk()]
),
])->save();
if ($previous) {
Storage::disk($this->profilePhotoDisk())->delete($previous);
}
});
}
/**
* Delete the user's profile photo.
*
* @return void
*/
public function deleteProfilePhoto()
{
if (is_null($this->profile_photo_path)) {
return;
}
Storage::disk($this->profilePhotoDisk())->delete($this->profile_photo_path);
$this->forceFill([
'profile_photo_path' => null,
])->save();
}
/**
* Get the URL to the user's profile photo.
*
* @return string
*/
public function getProfilePhotoUrlAttribute()
{
return $this->profile_photo_path
? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path)
: $this->defaultProfilePhotoUrl();
}
/**
* Get the default profile photo URL if no profile photo has been uploaded.
*
* @return string
*/
protected function defaultProfilePhotoUrl()
{
$name = trim(collect(explode(' ', $this->name))->map(function ($segment) {
return mb_substr($segment, 0, 1);
})->join(' '));
return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF';
}
/**
* Get the disk that profile photos should be stored on.
*
* @return string
*/
protected function profilePhotoDisk()
{
return isset($_ENV['VAPOR_ARTIFACT_NAME']) ? 's3' : config('jetstream.profile_photo_disk', 'public');
}
}