75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Http\Controllers\InformationController;
|
|
use App\Rules\PaymentRules\CawanganPermitUjrahPayment;
|
|
use App\Rules\PaymentRules\NorujukanBukanFasa2;
|
|
use App\Rules\PaymentRules\NorujukanContractNotExceed12Month;
|
|
use App\Rules\PaymentRules\NorujukanNotAttemptPaymentRecently;
|
|
use App\Rules\PaymentRules\NorujukanTidakAkanDilelong;
|
|
use App\Rules\PaymentRules\PaymentNotUjrah;
|
|
use App\Rules\PaymentRules\PilihMinimumSatuSAG;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class PaymentRequest extends FormRequest
|
|
{
|
|
public $selectedPembiayaan;
|
|
public $pembiayaanAkanDilelong;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$this->selectedPembiayaan = $this->getPembiayaanFromNorujukan();
|
|
$this->pembiayaanAkanDilelong = $this->getPembiayaanAkanDilelong();
|
|
|
|
return [
|
|
'totalSagInCartInput' => [
|
|
new PilihMinimumSatuSAG,
|
|
new NorujukanTidakAkanDilelong($this->pembiayaanAkanDilelong),
|
|
new NorujukanBukanFasa2($this->pembiayaanAkanDilelong),
|
|
new NorujukanNotAttemptPaymentRecently,
|
|
new CawanganPermitUjrahPayment($this->selectedPembiayaan),
|
|
// new PaymentNotUjrah($this->selectedPembiayaan),
|
|
new NorujukanContractNotExceed12Month($this->selectedPembiayaan),
|
|
]
|
|
];
|
|
}
|
|
|
|
public function getPembiayaanFromNorujukan()
|
|
{
|
|
$norujukanList = json_decode($this->totalSagInCartInput);
|
|
|
|
dd($norujukanList,$this->test);
|
|
|
|
|
|
// $list_pkb = array_filter($fn($x) => );
|
|
// $list_koop = array_filter($fn($x) => );
|
|
|
|
$pkb = array_map(fn($x) => Http::arrahn()->get('/api/gadai/norujukan/' . $x)->json()[0][0],$norujukanList);
|
|
$koop = array_map(fn($x) => Http::arrahn()->get('/api/gadai/norujukan/' . $x)->json()[0][0],$norujukanList);
|
|
|
|
return array_map(fn($x) => Http::arrahn()->get('/api/gadai/norujukan/' . $x)->json()[0][0], $norujukanList);
|
|
}
|
|
|
|
public function getPembiayaanAkanDilelong()
|
|
{
|
|
return (new InformationController())->pembiayaanakandilelong()->getData();
|
|
}
|
|
}
|