41 lines
823 B
PHP
41 lines
823 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* @mixin IdeHelperPayment
|
|
*/
|
|
class Payment extends Model
|
|
{
|
|
protected $fillable = [
|
|
'order_id',
|
|
'transaction_id',
|
|
'amount',
|
|
'currency',
|
|
'payment_method',
|
|
'payment_status_id',
|
|
'error_message',
|
|
];
|
|
|
|
protected $with = ['paymentStatus'];
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function paymentStatus(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PaymentStatus::class);
|
|
}
|
|
|
|
protected function status(): Attribute
|
|
{
|
|
return Attribute::make(fn () => $this->paymentStatus?->name);
|
|
}
|
|
}
|