some progress

This commit is contained in:
2025-10-06 22:35:04 +03:00
parent 07148700a5
commit beeda8139b
25 changed files with 770 additions and 32 deletions
+14
View File
@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
class Exercise extends Model
{
@@ -12,6 +13,7 @@ class Exercise extends Model
'slug',
'exercise_db_id',
'gif_url',
'poster_image',
'instructions',
];
@@ -66,4 +68,16 @@ class Exercise extends Model
$alias = $this->aliases()->where('user_id', $userId)->first();
return $alias?->name ?: $name;
}
public function getPosterUrlAttribute(): ?string
{
$poster = (string)($this->attributes['poster_image'] ?? '');
if ($poster === '') {
return null;
}
if (preg_match('/^https?:\/\//i', $poster)) {
return $poster;
}
return Storage::url($poster);
}
}
+3
View File
@@ -30,6 +30,7 @@ class User extends Authenticatable
'available_equipment',
'days_per_week',
'minutes_per_session',
'is_trainer',
];
/**
@@ -57,6 +58,8 @@ class User extends Authenticatable
'height_cm' => 'decimal:2',
'days_per_week' => 'integer',
'minutes_per_session' => 'integer',
'is_admin' => 'boolean',
'is_trainer' => 'boolean',
];
}
+4
View File
@@ -14,10 +14,14 @@ class WorkoutSessionItem extends Model
'session_id',
'workout_exercise_id',
'done',
'exercise_ms',
'rest_ms',
];
protected $casts = [
'done' => 'boolean',
'exercise_ms' => 'integer',
'rest_ms' => 'integer',
];
public function session(): BelongsTo