fix: billing bug feature
This commit is contained in:
parent
6208658a5c
commit
2972ae7de2
@ -65,7 +65,7 @@ class BillingController extends Controller
|
||||
$billing->updateSisa();
|
||||
|
||||
DB::commit();
|
||||
return redirect()->route('billing.show', $billing->IdBilling)
|
||||
return redirect()->route('billing.index', $billing->IdBilling)
|
||||
->with('success', 'Billing berhasil dibuat.');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
@ -27,10 +27,18 @@ class Billing extends Model
|
||||
return $this->belongsTo(TrRegistrasi::class, 'IdRegistrasi', 'IdRegistrasi');
|
||||
}
|
||||
|
||||
public function transaksi()
|
||||
{
|
||||
return $this->hasMany(TrTransaksi::class, 'IdRegistrasi', 'IdRegistrasi');
|
||||
}
|
||||
|
||||
// Mendapatkan detail transaksi untuk billing ini
|
||||
public function getTransaksiDetails()
|
||||
{
|
||||
return $this->registrasi->transaksi;
|
||||
if ($this->registrasi) {
|
||||
return $this->registrasi->transaksi ?? collect();
|
||||
}
|
||||
return collect();
|
||||
}
|
||||
|
||||
// Menghitung total biaya dari semua transaksi
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
@ -20,4 +21,19 @@ class TrRegistrasi extends Model
|
||||
'IdPegawai',
|
||||
'IdRuangPelayanan'
|
||||
];
|
||||
|
||||
public function billing()
|
||||
{
|
||||
return $this->hasOne(Billing::class, 'IdRegistrasi', 'IdRegistrasi');
|
||||
}
|
||||
|
||||
public function pasien(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MsPasien::class, 'MRPasien', 'MRPasien');
|
||||
}
|
||||
|
||||
public function transaksi()
|
||||
{
|
||||
return $this->hasMany(TrTransaksi::class, 'IdRegistrasi', 'IdRegistrasi');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user