<?php

namespace Rvsitebuilder\Wysiwyg\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddTagImageRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'imageKey' => 'required',
                'tag' => 'required',
                'solution' => 'required',
                'size' => 'required',
                'date' => 'required',
                'tagfolderID' => 'required',
                'override' => 'required',
        ];
    }

    public function authorize()
    {
        return $this->user()->isAdmin();
    }

    public function messages()
    {
        //TODO language system
        return [
                'imageKey.required' => __('wysiwyg::blog.validate.AddTagImage.imageKey.required'),
                'tag.required' => __('wysiwyg::blog.validate.AddTagImage.tag.required'),
                'solution.required' => __('wysiwyg::blog.validate.AddTagImage.solution.required'),
                'size.required' => __('wysiwyg::blog.validate.AddTagImage.size.required'),
                'date.required' => __('wysiwyg::blog.validate.AddTagImage.date.required'),
                'tagfolderID.required' => __('wysiwyg::blog.validate.AddTagImage.tagfolderID.required'),
                'override.required' => __('wysiwyg::blog.validate.AddTagImage.override.required'),
        ];
    }

    public function sanitize()
    {
        //TODO Define santize for model ให้ไปดูเพิ่มที่ https://laravel.com/docs/5.5/helpers#available-methods
        return [
                'imageKey' => 'clean',
                'tag' => 'clean',
                'solution' => 'clean',
                'size' => 'clean',
                'date' => 'clean',
                'tagfolderID' => 'clean',
                'override' => 'clean',
        ];
    }
}
