dashboard-admin/app/Models/transaction.php
2023-09-18 18:28:52 +07:00

62 lines
1.3 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 = [
'id',
'pembeli',
'penjual',
'nama_barang',
'deskripsi_transaksi',
'satuan_barang',
'harga_barang',
'jumlah_barang',
'persentase_keuntungan',
'total_keuntungan',
'biaya_admin',
'total_harga',
'total_bayar',
'token',
'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',
'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', 'id');
}
//Relasi
}