DONE: feature flags by branches

This commit is contained in:
ISMAIL MASSERAN
2026-09-08 14:48:18 +08:00
parent b6e4cf79ef
commit 120c32f781
9 changed files with 217 additions and 40 deletions
@@ -24,6 +24,30 @@ class PembiayaanOnlineController extends Controller
return Auth::user()->cawangan;
}
protected function cawanganInfo()
{
return $this->api()
->get(config('api.url') . '/api/cawangan/' . $this->kodcaw())
->json();
}
protected function isPembiayaanOnlineEnabled($cawangan_info = null)
{
if (!is_array($cawangan_info)) {
$cawangan_info = $this->cawanganInfo();
}
$features = $cawangan_info['features'] ?? [];
return !empty($features['pembiayaan_online']);
}
protected function abortUnlessPembiayaanOnline($cawangan_info = null)
{
if (!$this->isPembiayaanOnlineEnabled($cawangan_info)) {
abort(403, 'Pembiayaan online tidak diaktifkan untuk cawangan ini.');
}
}
/**
* PC senarai queue + batch history.
*/
@@ -33,9 +57,8 @@ class PembiayaanOnlineController extends Controller
$kodcaw = $this->kodcaw();
$api_url = config('api.url');
$cawangan_info = $this->api()
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
$cawangan_info = $this->cawanganInfo();
$this->abortUnlessPembiayaanOnline($cawangan_info);
$queue = $this->api()
->get($api_url . '/api/pembiayaan-online/' . $kodcaw . '/queue')
@@ -79,6 +102,7 @@ class PembiayaanOnlineController extends Controller
*/
public function updateLine(Request $request, $id)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$api_url = config('api.url');
@@ -109,6 +133,7 @@ class PembiayaanOnlineController extends Controller
*/
public function submitBatch(Request $request)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$api_url = config('api.url');
$auth_user = Auth::user();
@@ -150,9 +175,8 @@ class PembiayaanOnlineController extends Controller
$kodcaw = $this->kodcaw();
$api_url = config('api.url');
$cawangan_info = $this->api()
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
$cawangan_info = $this->cawanganInfo();
$this->abortUnlessPembiayaanOnline($cawangan_info);
$detail = $this->api()
->get($api_url . '/api/pembiayaan-online/' . $kodcaw . '/batches/' . $batchId)
@@ -181,9 +205,8 @@ class PembiayaanOnlineController extends Controller
$api_url = config('api.url');
$blastFilter = $request->input('blast_sent', '0');
$cawangan_info = $this->api()
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
$cawangan_info = $this->cawanganInfo();
$this->abortUnlessPembiayaanOnline($cawangan_info);
$query = [];
if ($blastFilter !== 'all' && $blastFilter !== '') {
@@ -219,6 +242,7 @@ class PembiayaanOnlineController extends Controller
*/
public function viewBukti($id)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$res = $this->api()
->get(config('api.url') . '/api/pembiayaan-online/' . $kodcaw . '/lines/' . $id . '/bukti');
@@ -258,6 +282,7 @@ class PembiayaanOnlineController extends Controller
*/
public function markBlast(Request $request)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$ids = $request->input('ids', []);
if (!is_array($ids)) {
@@ -572,9 +597,8 @@ class PembiayaanOnlineController extends Controller
$api_url = config('api.url');
$status = $request->input('status', '');
$cawangan_info = $this->api()
->get($api_url . '/api/cawangan/' . $kodcaw)
->json();
$cawangan_info = $this->cawanganInfo();
$this->abortUnlessPembiayaanOnline($cawangan_info);
$modal = $this->api()
->get($api_url . '/api/modal-online/' . $kodcaw)
@@ -624,6 +648,7 @@ class PembiayaanOnlineController extends Controller
*/
public function topupRequest(Request $request)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$amaun = (float) $request->input('amaun', 0);
@@ -742,6 +767,7 @@ class PembiayaanOnlineController extends Controller
*/
public function closeModal(Request $request)
{
$this->abortUnlessPembiayaanOnline();
$kodcaw = $this->kodcaw();
$res = $this->api()