dashboard-admin/app/Models/transaction.php

59 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;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'pembeli',
'penjual',
'judul_transaksi',
'deskripsi transaksi',
'persentase_keuntungan',
'total_keuntungan',
'harga',
'biaya_admin',
'total_harga',
'signature_key',
'metode_pembayaran',
'status',
'batas_pembayaran',
'batas_pengiriman_barang',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'batas_pembayaran' => 'datetime',
'batas_pengiriman_barang' => 'datetime',
'order_id' => 'string',
];
//Relasi
public function pembeli(){
return $this->belongsTo(User::class, 'email', 'pembeli');
}
public function penjual(){
return $this->belongsTo(User::class, 'email', 'penjual');
}
public function refunds(){
return $this->hasMany(Refund::class, 'order_id', 'order_id');
}
//Relasi
}