dashboard-admin/app/Models/transaction.php

65 lines
1.4 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',
'nama_barang',
'deskripsi_transaksi',
'satuan_barang',
'harga_barang',
'jumlah_barang',
'persentase_keuntungan',
'total_keuntungan',
'total_harga',
'total_bayar',
'token',
'status',
'batas_pembayaran',
'batas_pengiriman_barang_awal',
'batas_pengiriman_barang_akhir',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'batas_pembayaran' => 'datetime',
'batas_pengiriman_barang' => 'datetime',
'id' => 'string',
];
//Relasi
public function data_pembeli(){
return $this->belongsTo(User::class, 'pembeli', 'email');
}
public function data_penjual(){
return $this->belongsTo(User::class, 'penjual', 'email');
}
public function refunds(){
return $this->hasMany(Refund::class, 'transaction_id', 'id');
}
public function transactionDescription(){
return $this->hasMany(TransactionDescription::class, 'transaction_id', 'id');
}
//Relasi
}