File "OrderInvoice.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Models/OrderInvoice.php
File size: 722 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class OrderInvoice extends Model
{
    use HasFactory;
    protected $guarded = ['_token'];

    public function order(): BelongsTo
    {
        return $this->belongsTo(Order::class, 'order_id');
    }

    protected function getInvoiceUrlAttribute()
    {
        return $this->invoice_number
            ? asset('storage/order/'.$this->pdf)
            : '';
    }

    protected function getInvoicePathAttribute()
    {
        return $this->invoice_number
            ? public_path('storage/order/'.$this->pdf)
            : '';
    }
}