doudi1449 2017-01-08 23:01
浏览 172
已采纳

如何解决Class App \ Http \ Requests \ UpdateUserRequest不存在? laravel 5.3

My code is like this :

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Models\User;

class UpdateUserRequest 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 User::$rules;

        return [
            'username' => 'required|unique:users,username,'. \Auth::user()->id;,
            'email' => 'required|unique:users,email,'. \Auth::user()->id;,
        ];
    }
}

It is a request to update user data

When the code is executed, there is an error like this:

ReflectionException in Route.php line 339: Class App\Http\Requests\UpdateUserRequest does not exist

How to solve the error?

  • 写回答

1条回答 默认 最新

  • dslkchyv673627 2017-01-08 23:18
    关注

    You have syntax errors in both of your rules:

    'username' => 'required|unique:users,username,'. \Auth::user()->id;,
    

    Remove the semicolon:

    'username' => 'required|unique:users,username,'. \Auth::user()->id,
    

    You may also run into issues if someone happens to submit the form without being logged in, but that may or may not be a concern for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案