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;
}
}