FeedbackRequest.php 2.2 KB
<?php
/**
+----------------------------------------------------------------------------------------------------------------------
 * 数据验证层:Feedback 数据验证类
+----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Http\Requests
 * @package   App\Http\Requests
 * @author    Richer <yangzi1028@163.com>
 * @date      2020年12月28日 17:57:14
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Http\Requests;

/**
 * Class FeedbackRequest.
 *
 * @category  App\Http\Requests
 * @package   App\Http\Requests
 * @author    Richer <yangzi1028@163.com>
 * @date      2020年12月28日 17:57:14
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
class FeedbackRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get custom attributes for validator errors.
     *
     * @return array
     */
    public function attributes()
    {
        return [
//            'title'      => __('title'),
            'body'    => __('body'),
            'images'    => __('images'),
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $data = [
//            'title'      => 'required|min:1|max:255',
            'body'   => 'required|min:1|max:255',
            'images' => 'required|array',
        ];
        switch ($this->method()) {
            case 'POST':
                return $data;
            case 'PUT':
            case 'PATCH':
                return $data;
            case 'GET':
            case 'DELETE':
            default:
                return [];
        }
    }

    /**
     * 提示信息
     *
     * @return array
     */
    public function messages()
    {
        // 为了提示更准确,暂时不用框架自带的提示语句
        return [

        ];
    }
}