<?php

namespace Modules\Product\Models;

use Illuminate\Database\Eloquent\Model;
use Modules\Service\Uploads\UploadingService;

class ProductPhoto extends Model
{
    public $timestamps = false;

    protected $fillable =
        [
            'image',
            'product_id',
        ];

    public function setImageAttribute($value): void
    {
        if($value)
        {
            $file = UploadingService::uploadFile($value);
            $this->attributes['image'] = $file;
        }
        else
        {
            $this->attributes['image'] = $this->image;
        }
    }


}
