MOON
Server: Apache
System: Linux 101-53-147-124.cprapid.com 4.18.0-553.121.1.el8_10.x86_64 #1 SMP Thu Apr 30 09:06:34 EDT 2026 x86_64
User: clientsoftwares (1005)
PHP: 8.2.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/clientsoftwares/public_html/stocky.clientsoftwares.com/app/Models/Payment.php
<?php

namespace App\Models;

use App\Casts\Hash;
use App\Classes\Common;
use App\Models\BaseModel;
use App\Scopes\CompanyScope;
use Illuminate\Database\Eloquent\Builder;

class Payment extends BaseModel
{
    protected $table = 'payments';

    protected $default = ['xid'];

    protected $dates = ['date'];

    protected $guarded = ['id', 'warehouse_id', 'payment_type', 'created_at', 'updated_at'];

    protected $hidden = ['id', 'payment_mode_id', 'user_id'];

    protected $appends = ['xid', 'x_payment_mode_id', 'x_user_id'];

    protected $filterable = ['id', 'payment_number', 'payment_type', 'user_id'];

    protected $hashableGetterFunctions = [
        'getXPaymentModeIdAttribute' => 'payment_mode_id',
        'getXUserIdAttribute' => 'user_id',
    ];

    protected $casts = [
        'date' => 'datetime',
        'payment_mode_id' => Hash::class . ':hash',
        'user_id' => Hash::class . ':hash',
        'amount' => 'double',
        'unused_amount' => 'double',
        'paid_amount' => 'double',
        'unused_amount' => 'double',
    ];

    protected static function boot()
    {
        parent::boot();

        static::addGlobalScope(new CompanyScope);

        static::addGlobalScope('current_warehouse', function (Builder $builder) {
            $warehouse = warehouse();

            if ($warehouse) {
                $builder->where('payments.warehouse_id', $warehouse->id);
            }
        });
    }

    public function paymentMode()
    {
        return $this->belongsTo(PaymentMode::class);
    }

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