找不到Laravel表单要求类别

时间:2018-09-28 02:32:18

标签: php laravel laravel-5 controller backend

我正在尝试创建laravel表单验证,因此我使用以下代码创建了表单验证。问题是当我在控制器中键入请求提示时,出现错误“ Class App \ Http \ Requests \ RegisterForm不存在” 。任何帮助将不胜枚举。谢谢

RegisterForm.php

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RegisterForm extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name': 'required',
            'email': 'required',
            'mobile_number': 'required',
        ];
    }
}

UserController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests\RegisterForm;

class UserController extends Controller
{
    public function register(RegisterForm $request) {

    }

    public function login() {

    }
}

Laravel 5.7版 NGINX php7.2

1 个答案:

答案 0 :(得分:0)

问题是由在规则数组中使用冒号(:)而非=>引起的

import requests
import json
headers = {
    'Content-Type': 'application/json',
}

with open('user.json') as j:
    data = json.load(j)

response = requests.post('http://127.0.0.1:8080', 
                        headers=headers, 
                        json = data, 
                        auth=('Administrator', 'password'))
print(response.headers)