<?php

namespace App\Http\Requests\Api\User;

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

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $mimeTypes = implode(',', config('options.avatar.mime_types'));
        $maxImageSize = config('options.avatar.max_size');
        return [
            'image' => "required|mimes:{$mimeTypes}|max:{$maxImageSize}"
        ];
    }
}
