HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/be.naniguide.com/app/Model/PaymentMethod.php
<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use App\Library\Facades\Billing;
use App\Library\Traits\HasUid;
use App\Cashier\Contracts\PaymentMethodInfoInterface;

class PaymentMethod extends Model implements PaymentMethodInfoInterface
{
    use HasUid;

    protected $fillable = [
        'unique_id',
        'autobilling_data',
        'more_info',
        'payment_gateway_id',
        'can_auto_charge',
    ];

    public function scopeCanAutoCharge($query)
    {
        return $query->where('can_auto_charge', true);
    }

    public function paymentGateway()
    {
        return $this->belongsTo(PaymentGateway::class, 'payment_gateway_id');
    }

    public function getInformation()
    {
        return $this->more_info;
    }

    public function getMethodTitle(): string
    {
        return Billing::resolveService($this->paymentGateway)->getMethodTitle($this->getAutoBillingData());
    }

    public function getMethodInfo(): string
    {
        return Billing::resolveService($this->paymentGateway)->getMethodInfo($this->getAutoBillingData());
    }

    public function getAutoBillingData(): array
    {
        return json_decode($this->autobilling_data, true) ?? [];
    }

    public function getPaymentGatewayUid(): string
    {
        return $this->paymentGateway->uid;
    }
}