36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Access;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ReviewRoleApplicationRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$application = $this->route('application');
|
|
$requiresMenuGroup = $this->input('decision') === 'approved'
|
|
&& in_array($application?->application_type, ['tenant', 'staff'], true);
|
|
|
|
return [
|
|
'decision' => ['required', Rule::in(['approved', 'rejected'])], 'review_notes' => ['nullable', 'string', 'max:2000'],
|
|
'menu_group_id' => [
|
|
Rule::requiredIf($requiresMenuGroup),
|
|
'nullable',
|
|
'integer',
|
|
Rule::exists('menu_groups', 'id')->where('is_active', true),
|
|
],
|
|
'payment_type' => ['nullable', Rule::in(['prepaid', 'postpaid'])],
|
|
'price_mode' => ['nullable', Rule::in(['discount', 'commission'])],
|
|
'discount_percent' => ['nullable', 'numeric', 'min:0', 'max:100'], 'commission_percent' => ['nullable', 'numeric', 'min:0', 'max:100'],
|
|
'credit_limit' => ['nullable', 'numeric', 'min:0'],
|
|
];
|
|
}
|
|
}
|