<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Upload extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'file_original_name',
        'file_name',
        'user_id',
        'product_id',
        'extension',
        'type',
        'file_size',
    ];


    public function getFileUrlAttribute()
    {
        return asset('storage/products/' . $this->file_name);
    }

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