56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Transaction extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'transaction_code',
|
|
'category_id',
|
|
'admin_username',
|
|
'customer_name',
|
|
'customer_phone',
|
|
'customer_email',
|
|
'quantity',
|
|
'unit_price',
|
|
'total_amount',
|
|
'payment_method',
|
|
'payment_status',
|
|
'payment_proof',
|
|
'note',
|
|
'expires_at',
|
|
'reserved_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'expires_at' => 'datetime',
|
|
];
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
public function getPaymentMethodLabelAttribute()
|
|
{
|
|
return [
|
|
'cash' => 'Tunai',
|
|
'transfer' => 'Transfer Bank',
|
|
][$this->payment_method] ?? ucfirst($this->payment_method);
|
|
}
|
|
|
|
public function getPaymentStatusLabelAttribute()
|
|
{
|
|
return [
|
|
'pending' => 'Pending',
|
|
'paid' => 'Lunas',
|
|
'cancelled' => 'Dibatalkan',
|
|
][$this->payment_status] ?? ucfirst($this->payment_status);
|
|
}
|
|
}
|