<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class MediaItemCrop extends FormRequest
{

    /**
     * Get data to be validated from the request.
     *
     * @return array
     */
    public function validationData(): array
    {
        return [
            'x'         => $this->input('x', 0),
            'y'         => $this->input('y', 0),
            'width'     => $this->input('width', 0),
            'height'    => $this->input('height', 0)
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'x'         => 'integer',
            'y'         => 'integer',
            'width'     => 'required|integer|min:1',
            'height'    => 'required|integer|min:1'
        ];
    }
}
