<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreBusinessRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true; // restrict to admin/owner role at the route/policy level
    }

    public function rules(): array
    {
        $businessId = $this->route('business')?->id;

        return [
            'name' => ['required', 'string', 'max:255'],
            'ntn_cnic' => ['nullable', 'string', 'max:13'],
            'business_name' => ['nullable', 'string', 'max:255'],
            'province' => ['nullable', 'string', 'max:100'],
            'address' => ['nullable', 'string', 'max:500'],
            'email' => ['nullable', 'email', 'max:255'],
            'phone' => ['nullable', 'string', 'max:50'],
            'is_sandbox' => ['boolean'],
            'sandbox_token' => ['nullable', 'string'],
            'production_token' => ['nullable', 'string'],
            'auto_sync_enabled' => ['boolean'],
            'auto_sync_interval' => ['nullable', 'integer', 'min:1'],
            'is_active' => ['boolean'],
            'invoice_layout_template' => ['nullable', 'string', 'in:classic,elegant,slim'],
            'invoice_logo' => ['nullable', 'image', 'max:2048'],
        ];
    }
}
