<?php

namespace Rvsitebuilder\Wysiwyg\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SaveImageCommonRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'data' => 'required',
                'thumnail' => 'required',
                'imageURL' => 'required',
                'override' => 'required',
                'imageName' => 'required',
                'imageType' => 'required',
                'tagFolder' => 'required',
        ];
    }

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

    public function messages()
    {
        //TODO language system
        return [
                'data.required' => __('wysiwyg::blog.validate.SaveImageCommon.data.required'),
                'thumnail.required' => __('wysiwyg::blog.validate.SaveImageCommon.thumnail.required'),
                'imageURL.required' => __('wysiwyg::blog.validate.SaveImageCommon.imageURL.required'),
                'override.required' => __('wysiwyg::blog.validate.SaveImageCommon.override.required'),
                'imageName.required' => __('wysiwyg::blog.validate.SaveImageCommon.imageName.required'),
                'imageType.required' => __('wysiwyg::blog.validate.SaveImageCommon.imageType.required'),
                'tagFolder.required' => __('wysiwyg::blog.validate.SaveImageCommon.tagFolder.required'),
        ];
    }

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