| 12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Http\Requests;
- use Illuminate\Foundation\Http\FormRequest;
- class FinancialPlanAccountRequest extends FormRequest
- {
- public function rules(): array
- {
- $isCreate = $this->isMethod('POST');
- return [
- 'code' => [$isCreate ? 'required' : 'sometimes', 'string', 'max:50'],
- 'description' => [$isCreate ? 'required' : 'sometimes', 'string', 'max:255'],
- // chart_type é obrigatório só quando NÃO há pai; com pai, é herdado.
- 'chart_type' => [
- $isCreate ? 'required_without:parent_id' : 'sometimes',
- 'nullable',
- 'string',
- 'max:50',
- ],
- 'parent_id' => ['nullable', 'integer', 'exists:financial_plan_accounts,id'],
- 'order' => ['nullable', 'string', 'max:50'],
- 'unit_id' => ['nullable', 'integer', 'exists:units,id'],
- ];
- }
- }
|