mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
- 🛠️ 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:
@@ -63,7 +63,8 @@ class Meetup extends Model implements HasMedia
|
||||
->addMediaConversion('preview')
|
||||
->fit(Fit::Crop, 300, 300)
|
||||
->nonQueued();
|
||||
$this->addMediaConversion('thumb')
|
||||
$this
|
||||
->addMediaConversion('thumb')
|
||||
->fit(Fit::Crop, 130, 130)
|
||||
->width(130)
|
||||
->height(130);
|
||||
@@ -71,7 +72,8 @@ class Meetup extends Model implements HasMedia
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('logo')
|
||||
$this
|
||||
->addMediaCollection('logo')
|
||||
->singleFile()
|
||||
->useFallbackUrl(asset('img/einundzwanzig.png'));
|
||||
}
|
||||
@@ -101,7 +103,8 @@ class Meetup extends Model implements HasMedia
|
||||
}
|
||||
|
||||
return Attribute::make(
|
||||
get: fn() => url()->route('img',
|
||||
get: fn()
|
||||
=> url()->route('img',
|
||||
[
|
||||
'path' => $path,
|
||||
'w' => 900,
|
||||
@@ -117,9 +120,11 @@ class Meetup extends Model implements HasMedia
|
||||
$nextEvent = $this->meetupEvents()->where('start', '>=', now())->orderBy('start')->first();
|
||||
|
||||
return Attribute::make(
|
||||
get: fn() => $nextEvent ? [
|
||||
get: fn()
|
||||
=> $nextEvent ? [
|
||||
'start' => $nextEvent->start,
|
||||
'portalLink' => url()->route('meetups.landingpage-event', ['country' => $this->city->country, 'meetup' => $this, 'event' => $nextEvent]),
|
||||
'portalLink' => url()->route('meetups.landingpage-event',
|
||||
['country' => $this->city->country, 'meetup' => $this, 'event' => $nextEvent]),
|
||||
'location' => $nextEvent->location,
|
||||
'description' => $nextEvent->description,
|
||||
'link' => $nextEvent->link,
|
||||
@@ -130,6 +135,13 @@ class Meetup extends Model implements HasMedia
|
||||
);
|
||||
}
|
||||
|
||||
protected function belongsToMe(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => false,
|
||||
);
|
||||
}
|
||||
|
||||
public function meetupEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(MeetupEvent::class);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user