51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Rules\PaymentRules;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class PaymentNotUjrah implements Rule
|
|
{
|
|
public $pembiayaan;
|
|
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($pembiayaan)
|
|
{
|
|
$this->pembiayaan = $pembiayaan;
|
|
}
|
|
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function passes($attribute, $value)
|
|
{
|
|
$norujukanToPay = json_decode($value);
|
|
|
|
$isNorujukanUjrah = fn ($x) => $x['tagbaru'] === 1 ? true : false;
|
|
|
|
$norujukanUjrah = array_filter($this->pembiayaan, fn($x) => $isNorujukanUjrah($x));
|
|
|
|
return sizeof($norujukanUjrah) == 0;
|
|
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function message()
|
|
{
|
|
return 'Tidak dibenarkan pembayaran ujrah!';
|
|
}
|
|
}
|