<?php

namespace App\Models\Graphics;

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

class CustomGraphicsRequestMedia extends Model
{
    use SoftDeletes;

    protected $guarded = [];

    // explicitly define tables
    protected $table = 'custom_graphics_request_media';



    //the fillable fields
    protected $fillable = [
        'custom_graphics_requests_id', 'location', 'name', 'comment', 'type', 'size', 'location', 'path',
    ];

    /**
     * Relation of request to media
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function custom_graphics_requests(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->hasOne('App\Models\Graphics\CustomGraphicsRequest', 'id', 'custom_graphics_requests_id');
    }


    public function path(): string
    {
        return \url('/custom_request_media') . '/' . $this->id;
    }
}
