Writeoff/Livewire/HapusBuku/NomorPinjamanModal.php

43 lines
1.4 KiB
PHP
Raw Normal View History

2023-12-08 09:56:25 +00:00
<?php
namespace Modules\Writeoff\Livewire\HapusBuku;
use Livewire\Component;
use Modules\Writeoff\Entities\Rekening;
class NomorPinjamanModal extends Component
{
public $nomor_pinjaman;
public function render()
{
return view('writeoff::livewire.hapus-buku.nomor-pinjaman-modal');
}
public function submit()
{
$this->validate([
'nomor_pinjaman' => 'required',
]);
$rekenings = Rekening::with('product', 'debitur')
->where('nomor_rekening', $this->nomor_pinjaman)
->whereDoesntHave('hapusBuku')
->whereHas('product', function ($query) {
$query->whereBetween('kode', [3000, 3999]);
})
->get()->first();
if ($rekenings->count() > 0) {
$this->dispatch('show', json_encode($rekenings));
$this->dispatch('success', __('Nomor Pinjaman ditemukan'));
$this->redirect(route('pencatatan.hapus_buku.index', ['rekening' => json_encode($rekenings)]));
} else {
$this->addError('nomor_pinjaman', 'Nomor Pinjaman Salah Atau Nomor Pinjaman sudah terdaftar');
}
//$this->dispatch('showHapusBuku');
}
}