some progress
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user