RechargeOrderRequest.php 2.2 KB
<?php
/**
 +----------------------------------------------------------------------------------------------------------------------
 * 数据验证层:购物车 数据验证类
 +----------------------------------------------------------------------------------------------------------------------
 *
 * PHP version 7
 *
 * @category  App\Http\Requests
 * @package   App\Http\Requests
 * @author    Richer <yangzi1028@163.com>
 * @date      2022年5月12日13:38:22
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
namespace App\Http\Requests;

use Illuminate\Support\Str;

/**
 * Class RechargeOrderRequest.
 *
 * @category  App\Http\Requests
 * @package   App\Http\Requests
 * @author    Richer <yangzi1028@163.com>
 * @date      2022年5月12日13:38:22
 * @copyright 2020-2022 Richer (http://www.Richer.com/)
 * @license   http://www.Richer.com/ License
 * @link      http://www.Richer.com/
 */
class RechargeOrderRequest 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 [
            'quantity'  => __('quantity'),
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $data = [
            'quantity'          => 'required|int|min:1',
        ];

        switch ($this->method()) {
            // CREATE
            case 'POST':
                // CREATE ROLES
                return $data;
            // UPDATE
            case 'PUT':
            case 'PATCH':
                // UPDATE ROLES
                return [];
            case 'GET':
            case 'DELETE':
            default:
                return [];
        }
    }

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

        ];
    }
}