31 lines
734 B
PHP
31 lines
734 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class InvoiceAttachment extends Model
|
|
{
|
|
public const TYPE_PAYMENT_PROOF = 'payment_proof';
|
|
public const TYPE_DEPLOYMENT = 'deployment';
|
|
public const TYPE_CONTRACT = 'contract';
|
|
public const UPLOAD_RULE = 'required|file|mimes:jpg,jpeg,png,gif,webp,pdf,doc,docx,xls,xlsx|max:51200';
|
|
|
|
protected $table = 'invoice_attachments';
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $appends = ['url'];
|
|
|
|
public function invoice()
|
|
{
|
|
return $this->belongsTo(Invoice::class);
|
|
}
|
|
|
|
public function getUrlAttribute(): string
|
|
{
|
|
return Storage::disk($this->disk)->url($this->path);
|
|
}
|
|
}
|