ghassan c160242dbc WIP: storage-fix-local-nas work before playlist controls feature
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:15:20 +03:00

24 lines
515 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class PostImage extends Model
{
protected $fillable = ['post_id', 'filename', 'sort_order'];
public function post()
{
return $this->belongsTo(Post::class);
}
public function getImageUrlAttribute(): string
{
if (str_starts_with($this->filename, 'users/')) {
return route('media.post-image', $this->filename);
}
return asset('storage/post_images/' . $this->filename);
}
}