<?php

declare(strict_types=1);

namespace Builder\Core\Http\Requests\Resource;

final class UpdateResourceRequest extends ResourceRequest
{
    public function authorize(): bool
    {
        $permission = $this->getDefinition()->resolvePermissionForAction('update');

        return $this->userHasPermission($permission);
    }

    /** @return array<string, mixed> */
    public function rules(): array
    {
        return array_merge(
            $this->buildHandlerFieldRules(),
            $this->getDefinition()->getRulesForAction('update'),
        );
    }
}
