33 lines
790 B
PHP
33 lines
790 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class DetailPayment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'detail_payments';
|
|
|
|
public static function cekTunggakan($santri_id)
|
|
{
|
|
|
|
return self::where('status', 'unpaid')->whereHas('payment', function ($query) use ($santri_id) {
|
|
$query->where('santri_id', $santri_id);
|
|
})->orderBy('payment_year', 'asc')->orderBy('payment_month')->get();
|
|
}
|
|
|
|
public function payments()
|
|
{
|
|
return $this->belongsTo(Payment::class, 'payment_id', 'id');
|
|
}
|
|
|
|
public function paymentType()
|
|
{
|
|
return $this->belongsTo(PaymentType::class, 'type_id', 'id');
|
|
}
|
|
}
|