Class 'App \ Validator' not found laravel

Please help me get this error when creating the login and registration page in laravel 5.1

FatalErrorException in AuthController.php line 44:
Class 'App\Validator' not found

here is my AuthController.php

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Registration & Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users, as well as the
    | authentication of existing users. By default, this controller uses
    | a simple trait to add these behaviors. Why don't you explore it?
    |
    */

    use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    /**
     * Create a new authentication controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'getLogout']);
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);
    }
}

and my view register

<!-- resources/views/auth/register.blade.php -->

<form method="POST" action="/QADapps/auth/register">
    {!! csrf_field() !!}

    <div>
        Name
        <input type="text" name="name" value="{{ old('name') }}">
    </div>

    <div>
        Email
        <input type="email" name="email" value="{{ old('email') }}">
    </div>

    <div>
        Password
        <input type="password" name="password">
    </div>

    <div>
        Confirm Password
        <input type="password" name="password_confirmation">
    </div>

    <div>
        <button type="submit">Register</button>
    </div>
</form>

All codes are taken from the Laravel documentation. that’s why I don’t know why it fails. please check where i get the error. thank you

and this is my route controller

// Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');

PS my application is in the domain http: // localhost: 8080 / QADapps / auth / register. Are there any problems because of this? I also move index.php and .htaccess from shared to the root directory

+8
source share
2 answers

You really need either this:

use Validator;

or that:

use Illuminate\Support\Facades\Validator;

Illuminate\Validation\Validator - , , , , .

Illuminate\Support\Facades\Validator Validator config/app.php

+18

, , - , use Illuminate\Validation\Rule;

0

Source: https://habr.com/ru/post/1611529/


All Articles