<?php

namespace App\Http\Requests\Api\Gallery;

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

class GalleryUpdateRequest 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()
    {
        $validStates = implode(',', [Gallery::STATE_ACTIVE, Gallery::STATE_ARCHIVED]);
        return [
            'state' => "in:$validStates",
        ];
    }
}
