File "OrderPartialPayments.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Models/OrderPartialPayments.php
File size: 1.4 KB
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 OrderPartialPayments extends Model
{
    use HasFactory;

    protected $fillable = [
        'order_id',
        'charged_by_id',
        'payment_id',
        'payment_type',
        'cheque_number',
        'purchase_order_number',
        'purchase_order_copy',
        'amount',
        'created_at',
        'updated_at',
    ];

    public const PAYMENT_TYPE_RADIO = [
        'Cash'           => 'Cash',
        'Credit Card'    => 'Credit Card',
        'Purchase Order' => 'Purchase Order',
        'Check'         => 'Check',
        'PayJunction Invoice' => 'PayJunction Invoice',
    ];

    protected $dates = [
        'created_at',
        'updated_at',
    ];

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

    protected function user() {
        return $this->belongsTo(User::class, 'charged_by_id');
    }

    public function payment(): BelongsTo
    {
        return $this->belongsTo(PayJunctionPayments::class, 'payment_id');
    }

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