<?php

namespace App\Http\Requests\Api\Gallery;

use Illuminate\Foundation\Http\FormRequest;
use App\Support\Formatter;
use App\Models\Gallery\GalleryItem;

class GalleryItemUpdateRequest extends FormRequest
{
    public function __construct(Formatter $formatter)
    {
        $this->formatter = $formatter;
    }

    /**
     * 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()
    {
        $readyStatus = GalleryItem::STATUS_READY;
        return [
            'status' => "in:$readyStatus",
            'columns' => 'integer',
        ];
    }
}
