<?php

namespace Rvsitebuilder\Wysiwyg\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class SaveBrandRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'tel' => 'max:255',
                'logo' => 'max:255',
                'logo_mobile' => 'max:255',
                'linktohomepage' => 'max:255',
                'sitebrand' => 'max:255',
        ];
    }

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return $this->user()->isAdmin();
    }

    public function messages()
    {
        //TODO language system
        return [
                'tel' => __('wysiwyg::blog.validate.SaveBrand.tel'),
                'logo' => __('wysiwyg::blog.validate.SaveBrand.logo'),
                'logo_mobile' => __('wysiwyg::blog.validate.SaveBrand.logo_mobile'),
                'linktohomepage' => __('wysiwyg::blog.validate.SaveBrand.linktohomepage'),
                'sitebrand' => __('wysiwyg::blog.validate.SaveBrand.sitebrand'),
        ];
    }

    public function sanitize()
    {
        //TODO Define santize for model ให้ไปดูเพิ่มที่ https://laravel.com/docs/5.5/helpers#available-methods
        return [
                'tel' => 'trim|clean',
                'logo' => 'trim|clean',
                'logo_mobile' => 'trim|clean',
                'linktohomepage' => 'trim|clean',
                'sitebrand' => 'trim|clean',
        ];
    }
}
