update service and model manual payment
This commit is contained in:
parent
adcb956747
commit
6c73c3b808
|
@ -14,7 +14,7 @@ class PaymentController extends Controller
|
|||
*/
|
||||
public function index() {}
|
||||
|
||||
public function manualPayment()
|
||||
public function indexManualPayment()
|
||||
{
|
||||
$santri = Santri::with('payments', 'payments.detailPayments', 'payments.detailPayments.paymentType')->get();
|
||||
|
||||
|
@ -22,56 +22,12 @@ public function manualPayment()
|
|||
'santri' => $santri,
|
||||
'fields' => [
|
||||
'nis' => 'text',
|
||||
|
||||
'nama' => 'text',
|
||||
'status_santri' => 'text',
|
||||
'role_santri' => 'text',
|
||||
'penalty' => 'text',
|
||||
'amount' => 'text'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Payment $payment)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,10 @@ class DetailPayment extends Model
|
|||
|
||||
public static function cekTunggakan($santri_id)
|
||||
{
|
||||
return self::where('status', 'belum bayar')
|
||||
->whereHas('payment', function ($query) use ($santri_id) {
|
||||
$query->where('santri_id', $santri_id);
|
||||
})->orderBy('tahun_pembayaran', 'asc')
|
||||
->orderBy('bulan_pembayaran', 'asc')->first();
|
||||
|
||||
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 payment()
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\DetailPayment;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class CekDenda
|
||||
{
|
||||
public function cekDenda()
|
||||
{
|
||||
$prevMonth = Carbon::now()->subMonth()->month;
|
||||
$prevYear = Carbon::now()->subMonth()->year;
|
||||
$now = Carbon::now()->day;
|
||||
|
||||
if ($now >= 10) {
|
||||
$arrears = DetailPayment::where('status', 'unpaid')
|
||||
->where('payment_month', $prevMonth)
|
||||
->where('payment_year', $prevYear)->get();
|
||||
|
||||
foreach ($arrears as $arrear) {
|
||||
$arrear->update([
|
||||
'penalty' => 20000
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return ['message' => 'Berhasil'];
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ public function up(): void
|
|||
$table->id();
|
||||
$table->string('nis');
|
||||
$table->string('password');
|
||||
$table->string('role');
|
||||
$table->string('level');
|
||||
$table->foreignId('santri_id')->constrained('santris')->onDelete('cascade');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
|
|
@ -14,11 +14,11 @@ public function up(): void
|
|||
Schema::create('detail_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('payment_id')->constrained('payments')->onDelete('cascade');
|
||||
$table->enum('status', ['bayar', 'belum bayar']);
|
||||
$table->enum('status', ['paid', 'unpaid']);
|
||||
$table->float('amount');
|
||||
$table->float('penalty')->nullable();
|
||||
$table->integer('bulan_pembayaran');
|
||||
$table->integer('tahun_pembayaran');
|
||||
$table->integer('payment_month');
|
||||
$table->integer('payment_year');
|
||||
$table->foreignId('type_id')->constrained('payment_types')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue