jeudi 27 septembre 2018

Laravel form request class not found

I'm trying to create laravel form validation, so I created a form validation with the following code. The problem is that I'm getting an error "Class App\Http\Requests\RegisterForm does not exist" when I typehint the request in controller. Any help would be much appriciated. Thanks

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 version 5.7 NGINX php7.2



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2xDZcbR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire