<?php

namespace App\Http\Requests\Api\Gallery;

use Illuminate\Foundation\Http\FormRequest;

class UpdateOrderRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        $user = auth()->user();

        return $user->mainAccount->uid === $this->route('accountUid');
    }


    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'itemOrder' => 'array',
            'itemOrder.*.uid' => "required_with:itemOrder|alpha_num",
            'itemOrder.*.position' => "required_with:itemOrder|integer",
        ];
    }
}
