File "UpdateAccountRequest.php"

Full Path: /var/www/html/back/app/Domain/Account/Requests/UpdateAccountRequest.php
File size: 1.86 KB
MIME-type: text/x-php
Charset: utf-8

<?php

declare(strict_types=1);

namespace App\Domain\Account\Requests;

use App\BaseClasses\BaseApiRequest;

class UpdateAccountRequest extends BaseApiRequest
{
    /**
     * Описание параметров тела запроса для документации API.
     *
     * @return array[]
     */
    public static function bodyParameters(): array
    {
        return [
            'model_id' => [
                'description' => 'ID модели, к которой привязан счет (необязательно)',
                'example' => 1,
            ],
            'name' => [
                'description' => 'Название счета (необязательно)',
                'example' => 'Резервный счет',
            ],
            'organization_id' => [
                'description' => 'ID организации, связанной со счетом (необязательно)',
                'example' => 3,
            ],
            'deposit' => [
                'description' => 'Обновленное значение депозита счета (необязательно)',
                'example' => 5000.00,
            ],
        ];
    }

    public static function example(): array
    {
        return [
            'model_id' => 1,
            'name' => 'Резервный счет',
            'organization_id' => 3,
            'deposit' => 5000.00,
        ];
    }

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'model_id' => 'sometimes|integer|exists:models,id',
            'name' => 'sometimes|string|max:255',
            'organization_id' => 'sometimes|integer|exists:organizations,id',
            'deposit' => 'sometimes|numeric',
            'account_id' => 'integer|exists:accounts,id',
        ];
    }
}