87 lines
2.9 KiB
PHP
87 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\Support\Str;
|
|
|
|
use DataTables;
|
|
use GuzzleHttp\Client;
|
|
use Carbon\Carbon;
|
|
|
|
use App\Models\Alternatif;
|
|
use App\Models\PengajuanNasabah;
|
|
use App\Models\Nilai;
|
|
|
|
class PengajuanController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
if ($request->ajax()) {
|
|
$data = PengajuanNasabah::select('*');
|
|
// Convert the Eloquent Collection to a regular PHP array
|
|
$data->each(function ($item, $key) {
|
|
$item->rowIndex = $key + 1;
|
|
});
|
|
|
|
return Datatables::of($data)
|
|
->addIndexColumn()
|
|
->addColumn('nasabah', function($row){
|
|
return $row->nasabah->nama_alternatif;
|
|
})
|
|
->addColumn('uplink', function($row){
|
|
return 'aa';
|
|
})
|
|
->addColumn('status_pengajuan', function($row){
|
|
if ($row->status == 1) {
|
|
return '<span class="mb-1 badge font-medium badge-success py-2 px-3 fs-7">Diterima</span>';
|
|
} elseif($row->status == 0) {
|
|
return '<span class="mb-1 badge font-medium badge-primary py-2 px-3 fs-7">Menunggu Respon</span>';
|
|
} else {
|
|
return '<span class="mb-1 badge font-medium badge-danger py-2 px-3 fs-7">Tidak diterima</span>';
|
|
}
|
|
})
|
|
->rawColumns(['nasabah', 'uplink', 'status_pengajuan'])
|
|
->make(true);
|
|
}
|
|
|
|
$data = [
|
|
'subtitle' => 'Pengajuan Nasabah'
|
|
];
|
|
|
|
return view('admin.app.content.pengajuan.index', compact('data'));
|
|
}
|
|
|
|
public function accept($id)
|
|
{
|
|
$pengajuan = PengajuanNasabah::find($id);
|
|
if($pengajuan) {
|
|
$pengajuan->status = 1;
|
|
$pengajuan->save();
|
|
// $checkNilai = Nilai::where('alternatif_kode', $pengajuan->id_nasabah);
|
|
// $checkNilai->delete();
|
|
// $checkNasabah = Alternatif::where('id_alternatif', $pengajuan->id_nasabah);
|
|
// $checkNasabah->delete();
|
|
return redirect()->back()->with('success', 'Pengajuan Berhasil di Setujui');
|
|
} else {
|
|
return redirect()->back()->with('error', 'Pengajuan Tidak Ditemukan');
|
|
}
|
|
}
|
|
|
|
public function decline($id)
|
|
{
|
|
$pengajuan = PengajuanNasabah::find($id);
|
|
if($pengajuan) {
|
|
$pengajuan->status = 2;
|
|
$pengajuan->save();
|
|
return redirect()->back()->with('success', 'Pengajuan Berhasil ditolak');
|
|
} else {
|
|
return redirect()->back()->with('error', 'Pengajuan Tidak Ditemukan');
|
|
}
|
|
}
|
|
}
|