<commit_before><?php

namespace Knot\Models;

use Illuminate\Database\Eloquent\Model;
use Knot\Traits\Postable;

class PhotoPost extends Model
{
    use Postable;

    protected $table = 'photo_posts';

    protected $fillable = ['user_id', 'body', 'image_path', 'width', 'height'];

    protected $appends = ['imageUrl'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function getImageUrlAttribute()
    {
        $path = config('filesystems.disks.b2.basePath');
        $bucket = config('filesystems.disks.b2.bucketName');
        $imagePath = $this->attributes['image_path'];
        if (starts_with($imagePath, 'photo-posts')) {
            return "{$path}{$bucket}/{$imagePath}";
        } else {
            return asset('images/tmp/'.pathinfo($imagePath, PATHINFO_BASENAME));
        }
    }
}<commit_msg>Hides image_path during serialization on photo posts<commit_after><?php

namespace Knot\Models;

use Illuminate\Database\Eloquent\Model;
use Knot\Traits\Postable;

class PhotoPost extends Model
{
    use Postable;

    protected $table = 'photo_posts';

    protected $fillable = [
        'user_id',
        'body',
        'image_path',
        'width',
        'height',
    ];

    protected $hidden = ['image_path'];

    protected $appends = ['image_url'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function getImageUrlAttribute()
    {
        $path = config('filesystems.disks.b2.basePath');
        $bucket = config('filesystems.disks.b2.bucketName');
        $imagePath = $this->image_path;
        if (starts_with($imagePath, 'photo-posts')) {
            return "{$path}{$bucket}/{$imagePath}";
        } else {
            return asset('images/tmp/'.pathinfo($imagePath, PATHINFO_BASENAME));
        }
    }
}
{'fraction_non_alphanumeric': 0.1454940282301846, 'fraction_numerical': 0.002171552660152009, 'mean_word_length': 2.8078512396694215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5251973', 'n_tokens_mistral': 584, 'n_tokens_neox': 567, 'n_words': 107}