Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Payment | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| order | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| statusEnum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Enums\PaymentStatus; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | class Payment extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $table = 'payments'; |
| 14 | |
| 15 | protected $fillable = [ |
| 16 | 'order_id', |
| 17 | 'customer_id', |
| 18 | 'status', |
| 19 | 'gateway', |
| 20 | 'transaction_id', |
| 21 | 'meta', |
| 22 | 'total', |
| 23 | 'shipping_cost', |
| 24 | 'payment_type', |
| 25 | 'payment_note', |
| 26 | 'paid', |
| 27 | 'created_by', |
| 28 | 'updated_by', |
| 29 | ]; |
| 30 | |
| 31 | protected $casts = [ |
| 32 | 'meta' => 'array', |
| 33 | ]; |
| 34 | |
| 35 | public function order() |
| 36 | { |
| 37 | return $this->belongsTo(Order::class, 'order_id', 'id'); |
| 38 | } |
| 39 | |
| 40 | public function statusEnum(): PaymentStatus |
| 41 | { |
| 42 | return PaymentStatus::fromStored($this->status); |
| 43 | } |
| 44 | } |