<?php

namespace App\Http\Requests;

use App\Models\Promoter;
use Illuminate\Foundation\Http\FormRequest;

class PromoterRequest extends FormRequest
{
    use PartnerAccountRules;

    public function authorize(): bool
    {
        $promoter = $this->route('promoter');

        return $promoter
            ? $this->user()->can('update', $promoter)
            : $this->user()->can('create', Promoter::class);
    }

    public function rules(): array
    {
        $ignoreUserId = $this->route('promoter')?->user_id;

        return array_merge($this->accountRules($ignoreUserId), $this->officialRules());
    }
}
