71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V3\Dashboard\Harim\HarimOffice;
|
|
|
|
use App\Enums\HarimStates;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Validator;
|
|
|
|
class ComputingPaymentRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->harim->province_id == auth()->user()->province_id &&
|
|
$this->harim->state_id == HarimStates::BARESI_ARSE_VA_AYAN_ERSAL_SHODE_TAVASOT_DAFTAR_HARIM->value;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'traffic' => 'required|numeric|decimal:0,1',
|
|
'road_type' => 'required|numeric|decimal:0,1',
|
|
'position' => 'required|numeric|decimal:0,1',
|
|
'final_area_space' => 'required|numeric|decimal:0,2', //عرصه
|
|
'final_plan_space' => 'required|numeric|decimal:0,2', // عیان
|
|
'payment_amount' => 'required|numeric',
|
|
'expert_description' => 'required|string',
|
|
];
|
|
}
|
|
|
|
public function after(): array
|
|
{
|
|
return [
|
|
function () {
|
|
$fe = config('harim_web_services.Harim_Payment.per');
|
|
$arse = (
|
|
$this->traffic *
|
|
$this->road_type *
|
|
$this->position *
|
|
$fe*
|
|
$this->final_area_space
|
|
);
|
|
$ayan =(
|
|
$this->traffic *
|
|
$this->road_type *
|
|
$this->position *
|
|
$fe*
|
|
$this->final_plan_space
|
|
);
|
|
$result = floor($arse + $ayan);
|
|
|
|
if ($result !== $this->payment_amount) {
|
|
$this->validator->errors()->add(
|
|
'payment_amount',
|
|
'payment_amount مقادیر بدست امده صحیح نمی باشد.'
|
|
);
|
|
}
|
|
}
|
|
];
|
|
}
|
|
|
|
}
|