53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Carbon\Carbon;
|
|
|
|
class ObatKeluar extends Model
|
|
{
|
|
protected $fillable = [
|
|
'obat_masuk_id',
|
|
'nama_obat',
|
|
'sumber_dana',
|
|
'user_id',
|
|
'kode_batch',
|
|
'barcode',
|
|
'jumlah',
|
|
'harga',
|
|
'harga_total',
|
|
'tujuan_pemakaian',
|
|
'tanggal_pengeluaran',
|
|
'tanggal_kadaluarsa',
|
|
'no_pengeluaran',
|
|
'nama_petugas',
|
|
'nama_penerima',
|
|
'catatan',
|
|
'status',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tanggal_pengeluaran' => 'date',
|
|
'tanggal_kadaluarsa' => 'date',
|
|
'harga' => 'decimal:2',
|
|
'harga_total' => 'decimal:2',
|
|
];
|
|
|
|
public function obatMasuk(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ObatMasuk::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function getSisaHariAttribute(): int
|
|
{
|
|
return Carbon::now()->diffInDays($this->tanggal_kadaluarsa, false);
|
|
}
|
|
}
|