<commit_before><?php namespace Pingpong\Cms\Post\Entities;
   
use Illuminate\Database\Eloquent\Model;
use Pingpong\Cms\Core\Entities\User;
use Pingpong\Support\Traits\Imageable;
use Pingpong\Support\Traits\Publishable;

class Post extends Model {

	use Imageable, Publishable;

    protected $fillable = [
    	'user_id',
    	'type',
    	'title',
    	'slug',
    	'body',
    	'image',
    	'published_at'
    ];

    const PUBLISHED_AT = 'published_at';

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

}<commit_msg>automatic upload image when creating post<commit_after><?php namespace Pingpong\Cms\Post\Entities;
   
use Illuminate\Database\Eloquent\Model;
use Pingpong\Cms\Core\Entities\User;
use Pingpong\Support\Traits\Imageable;
use Pingpong\Support\Traits\Publishable;

class Post extends Model {

	use Imageable, Publishable;

    protected $fillable = [
    	'user_id',
    	'type',
    	'title',
    	'slug',
    	'body',
    	'image',
    	'published_at'
    ];

    const PUBLISHED_AT = 'published_at';

    public static $path = 'images/posts/'; 

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

    public function setImageAttribute($value)
    {
        if ($value instanceof UploadedFile) {
            $this->attributes['image'] = upload_image(
                $value,
                static::$path,
                'post.uploaded'
            );
        } else {
            $this->attributes['image'] = $value;
        }
    }

}
{'fraction_non_alphanumeric': 0.12541037426132634, 'fraction_numerical': 0.0, 'mean_word_length': 2.503448275862069, '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': '1153129', 'n_tokens_mistral': 525, 'n_tokens_neox': 517, 'n_words': 94}