APP als Hybrid Version - Anbindung an API

This commit is contained in:
Kevin Adametz 2026-06-05 09:54:12 +02:00
parent d054732bf5
commit c1514999be
46 changed files with 3418 additions and 196 deletions

View file

@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Event extends Model
{
@ -35,4 +36,9 @@ class Event extends Model
{
return $this->belongsTo(User::class);
}
public function media(): HasMany
{
return $this->hasMany(EventMedia::class);
}
}

View file

@ -0,0 +1,66 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class EventMedia extends Model
{
/** @use HasFactory<\Database\Factories\EventMediaFactory> */
use HasFactory;
protected $fillable = [
'uuid',
'user_id',
'event_id',
'collection',
'name',
'mime_type',
'disk',
'path',
'thumbnail_path',
'preview_path',
'size',
'width',
'height',
'thumbnail_width',
'thumbnail_height',
'preview_width',
'preview_height',
];
protected function casts(): array
{
return [
'size' => 'integer',
'width' => 'integer',
'height' => 'integer',
'thumbnail_width' => 'integer',
'thumbnail_height' => 'integer',
'preview_width' => 'integer',
'preview_height' => 'integer',
];
}
protected static function booted(): void
{
static::creating(function (EventMedia $media): void {
if (! $media->uuid) {
$media->uuid = (string) Str::uuid();
}
});
}
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View file

@ -5,6 +5,7 @@ namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
@ -57,6 +58,11 @@ class User extends Authenticatable
return $this->hasMany(Event::class);
}
public function settings(): HasOne
{
return $this->hasOne(UserSetting::class);
}
public function initials(): string
{
return Str::of($this->name)

View file

@ -0,0 +1,29 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class UserSetting extends Model
{
/** @use HasFactory<\Database\Factories\UserSettingFactory> */
use HasFactory;
protected $fillable = [
'settings',
];
protected function casts(): array
{
return [
'settings' => 'array',
];
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}