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'); } }